@wazo/sdk 0.39.15 → 0.40.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/README.md +2 -2
- package/dist/wazo-sdk.js +12 -12
- package/esm/__tests__/api-client.test.js +0 -10
- package/esm/__tests__/web-rtc-client.test.js +2 -15
- package/esm/api/chatd.js +0 -1
- package/esm/api/dird.js +7 -10
- package/esm/checker/checks/ice-ipv4.js +2 -3
- package/esm/checker/checks/symmetric-nat.js +7 -4
- package/esm/domain/AdHocAPIConference.js +1 -1
- package/esm/domain/CallLog.js +1 -1
- package/esm/domain/Contact.js +2 -1
- package/esm/domain/MeetingAuthorization.js +6 -0
- package/esm/domain/Phone/CTIPhone.js +2 -0
- package/esm/domain/Phone/WebRTCPhone.js +16 -18
- package/esm/domain/Session.js +2 -2
- package/esm/domain/__tests__/Agent.test.js +0 -2
- package/esm/domain/__tests__/Call.test.js +0 -1
- package/esm/domain/__tests__/CallLog.test.js +0 -1
- package/esm/domain/__tests__/CallSession.test.js +1 -2
- package/esm/domain/__tests__/Contact.test.js +2 -4
- package/esm/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/esm/domain/__tests__/Profile.test.js +0 -1
- package/esm/domain/__tests__/Room.test.js +1 -25
- package/esm/domain/__tests__/Session.test.js +13 -14
- package/esm/domain/__tests__/SipLine.test.js +2 -3
- package/esm/index.js +42 -88
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -15
- package/esm/service/IssueReporter.js +1 -3
- package/esm/service/__tests__/IssueReporter.test.js +0 -1
- package/esm/simple/Phone.js +1 -1
- package/esm/simple/Websocket.js +2 -2
- package/esm/simple/index.js +5 -4
- package/esm/simple/room/Room.js +15 -15
- package/esm/simple/room/SipRoom.js +1 -1
- package/esm/simple/room/Stream.js +1 -2
- package/esm/simple/room/__tests__/Participant.test.js +0 -2
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/esm/types/api/auth.d.ts +2 -2
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/api/call-logd.d.ts +3 -3
- package/esm/types/api/call-logd.d.ts.map +1 -1
- package/esm/types/api/chatd.d.ts +9 -22
- package/esm/types/api/chatd.d.ts.map +1 -1
- package/esm/types/api/dird.d.ts +21 -14
- package/esm/types/api/dird.d.ts.map +1 -1
- package/esm/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +1 -1
- package/esm/types/checker/checks/symmetric-nat.d.ts.map +1 -1
- package/esm/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/esm/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/esm/types/domain/Agent.d.ts +1 -1
- package/esm/types/domain/Agent.d.ts.map +1 -1
- package/esm/types/domain/CallLog.d.ts +14 -26
- package/esm/types/domain/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -4
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Contact.d.ts +8 -0
- package/esm/types/domain/Contact.d.ts.map +1 -1
- package/esm/types/domain/MeetingAuthorization.d.ts +6 -0
- package/esm/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/Phone.d.ts +12 -2
- package/esm/types/domain/Phone/Phone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/Room.d.ts +10 -12
- package/esm/types/domain/Room.d.ts.map +1 -1
- package/esm/types/domain/Session.d.ts +1 -1
- package/esm/types/domain/Session.d.ts.map +1 -1
- package/esm/types/domain/SipLine.d.ts +3 -3
- package/esm/types/domain/SipLine.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +64 -10
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +51 -314
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +3 -3
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/service/IssueReporter.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +0 -40
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +0 -113
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/Websocket.d.ts +0 -16
- package/esm/types/simple/Websocket.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +8 -8
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/simple/room/Participant.d.ts +4 -3
- package/esm/types/simple/room/Participant.d.ts.map +1 -1
- package/esm/types/simple/room/Room.d.ts +29 -18
- package/esm/types/simple/room/Room.d.ts.map +1 -1
- package/esm/types/simple/room/SipRoom.d.ts +1 -1
- package/esm/types/simple/room/SipRoom.d.ts.map +1 -1
- package/esm/types/simple/room/Stream.d.ts +1 -1
- package/esm/types/simple/room/Stream.d.ts.map +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/esm/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +20 -5
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +51 -49
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/types/websocket-client.d.ts.map +1 -1
- package/esm/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/esm/utils/__tests__/api-requester.test.js +0 -2
- package/esm/utils/__tests__/sdp.test.js +4 -18
- package/esm/utils/api-requester.js +1 -2
- package/esm/utils/sdp.js +8 -3
- package/esm/web-rtc-client.js +99 -136
- package/esm/websocket-client.js +1 -2
- package/index.js +1 -0
- package/lib/__tests__/api-client.test.js +0 -10
- package/lib/__tests__/web-rtc-client.test.js +2 -15
- package/lib/api/chatd.js +0 -1
- package/lib/api/dird.js +19 -22
- package/lib/checker/checks/ice-ipv4.js +2 -3
- package/lib/checker/checks/symmetric-nat.js +7 -4
- package/lib/domain/AdHocAPIConference.js +1 -1
- package/lib/domain/CallLog.js +1 -1
- package/lib/domain/Contact.js +2 -1
- package/lib/domain/MeetingAuthorization.js +6 -0
- package/lib/domain/Phone/CTIPhone.js +2 -0
- package/lib/domain/Phone/WebRTCPhone.js +16 -18
- package/lib/domain/Session.js +2 -2
- package/lib/domain/__tests__/Agent.test.js +0 -2
- package/lib/domain/__tests__/Call.test.js +0 -1
- package/lib/domain/__tests__/CallLog.test.js +0 -1
- package/lib/domain/__tests__/CallSession.test.js +1 -2
- package/lib/domain/__tests__/Contact.test.js +2 -4
- package/lib/domain/__tests__/IndirectTransfer.test.js +0 -1
- package/lib/domain/__tests__/Profile.test.js +0 -1
- package/lib/domain/__tests__/Room.test.js +1 -25
- package/lib/domain/__tests__/Session.test.js +13 -14
- package/lib/domain/__tests__/SipLine.test.js +2 -3
- package/lib/index.js +93 -99
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -15
- package/lib/service/IssueReporter.js +1 -3
- package/lib/service/__tests__/IssueReporter.test.js +0 -1
- package/lib/simple/Phone.js +1 -1
- package/lib/simple/Websocket.js +2 -2
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +17 -15
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/simple/room/Stream.js +1 -2
- package/lib/simple/room/__tests__/Participant.test.js +0 -2
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +1 -2
- package/lib/types/api/auth.d.ts +2 -2
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/api/call-logd.d.ts +3 -3
- package/lib/types/api/call-logd.d.ts.map +1 -1
- package/lib/types/api/chatd.d.ts +9 -22
- package/lib/types/api/chatd.d.ts.map +1 -1
- package/lib/types/api/dird.d.ts +21 -14
- package/lib/types/api/dird.d.ts.map +1 -1
- package/lib/types/checker/checks/ice-ipv4.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +1 -1
- package/lib/types/checker/checks/symmetric-nat.d.ts.map +1 -1
- package/lib/types/checker/checks/webrtc-transport.d.ts +2 -2
- package/lib/types/checker/checks/webrtc-transport.d.ts.map +1 -1
- package/lib/types/domain/Agent.d.ts +1 -1
- package/lib/types/domain/Agent.d.ts.map +1 -1
- package/lib/types/domain/CallLog.d.ts +14 -26
- package/lib/types/domain/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -4
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Contact.d.ts +8 -0
- package/lib/types/domain/Contact.d.ts.map +1 -1
- package/lib/types/domain/MeetingAuthorization.d.ts +6 -0
- package/lib/types/domain/MeetingAuthorization.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts +2 -0
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/Phone.d.ts +12 -2
- package/lib/types/domain/Phone/Phone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +24 -20
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/Room.d.ts +10 -12
- package/lib/types/domain/Room.d.ts.map +1 -1
- package/lib/types/domain/Session.d.ts +1 -1
- package/lib/types/domain/Session.d.ts.map +1 -1
- package/lib/types/domain/SipLine.d.ts +3 -3
- package/lib/types/domain/SipLine.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +64 -10
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +51 -314
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +5 -4
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +3 -3
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/service/IssueReporter.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +0 -40
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +0 -113
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/Websocket.d.ts +0 -16
- package/lib/types/simple/Websocket.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +8 -8
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/simple/room/Participant.d.ts +4 -3
- package/lib/types/simple/room/Participant.d.ts.map +1 -1
- package/lib/types/simple/room/Room.d.ts +29 -18
- package/lib/types/simple/room/Room.d.ts.map +1 -1
- package/lib/types/simple/room/SipRoom.d.ts +1 -1
- package/lib/types/simple/room/SipRoom.d.ts.map +1 -1
- package/lib/types/simple/room/Stream.d.ts +1 -1
- package/lib/types/simple/room/Stream.d.ts.map +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts +1 -1
- package/lib/types/utils/PhoneNumberUtil.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +20 -5
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +51 -49
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/types/websocket-client.d.ts.map +1 -1
- package/lib/utils/__tests__/PhoneNumberUtil.test.js +0 -6
- package/lib/utils/__tests__/api-requester.test.js +0 -2
- package/lib/utils/__tests__/sdp.test.js +6 -18
- package/lib/utils/api-requester.js +2 -3
- package/lib/utils/sdp.js +9 -3
- package/lib/web-rtc-client.js +105 -140
- package/lib/websocket-client.js +1 -2
- package/package.json +5 -18
- package/src/__tests__/api-client.test.ts +10 -19
- package/src/__tests__/web-rtc-client.test.ts +13 -25
- package/src/api/auth.ts +2 -5
- package/src/api/call-logd.ts +3 -3
- package/src/api/chatd.ts +10 -24
- package/src/api/dird.ts +33 -39
- package/src/checker/checks/ice-ipv4.ts +4 -5
- package/src/checker/checks/symmetric-nat.ts +11 -7
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/domain/AdHocAPIConference.ts +1 -1
- package/src/domain/Agent.ts +1 -1
- package/src/domain/CallLog.ts +19 -27
- package/src/domain/CallSession.ts +3 -4
- package/src/domain/Contact.ts +3 -1
- package/src/domain/MeetingAuthorization.ts +13 -0
- package/src/domain/Phone/CTIPhone.ts +4 -0
- package/src/domain/Phone/Phone.ts +11 -2
- package/src/domain/Phone/WebRTCPhone.ts +51 -52
- package/src/domain/Room.ts +12 -14
- package/src/domain/Session.ts +3 -3
- package/src/domain/SipLine.ts +3 -3
- package/src/domain/__tests__/Agent.test.ts +3 -5
- package/src/domain/__tests__/Call.test.ts +4 -5
- package/src/domain/__tests__/CallLog.test.ts +1 -3
- package/src/domain/__tests__/CallSession.test.ts +10 -11
- package/src/domain/__tests__/Contact.test.ts +2 -4
- package/src/domain/__tests__/IndirectTransfer.test.ts +6 -7
- package/src/domain/__tests__/Profile.test.ts +3 -4
- package/src/domain/__tests__/Room.test.ts +27 -51
- package/src/domain/__tests__/Session.test.ts +27 -28
- package/src/domain/__tests__/SipLine.test.ts +4 -5
- package/src/domain/types.ts +64 -11
- package/src/index.ts +51 -111
- package/src/lib/WazoSessionDescriptionHandler.ts +24 -30
- package/src/service/CallApi.ts +3 -3
- package/src/service/IssueReporter.ts +3 -5
- package/src/service/__tests__/IssueReporter.test.ts +1 -2
- package/src/simple/Auth.ts +1 -41
- package/src/simple/Phone.ts +9 -116
- package/src/simple/Websocket.ts +4 -20
- package/src/simple/index.ts +8 -7
- package/src/simple/room/Participant.ts +4 -3
- package/src/simple/room/Room.ts +44 -36
- package/src/simple/room/SipRoom.ts +4 -4
- package/src/simple/room/Stream.ts +2 -3
- package/src/simple/room/__tests__/Participant.test.ts +2 -4
- package/src/simple/room/__tests__/RemoteParticipant.test.ts +4 -3
- package/src/types/wazo.d.ts +1 -0
- package/src/utils/PhoneNumberUtil.ts +1 -1
- package/src/utils/__tests__/PhoneNumberUtil.test.ts +0 -6
- package/src/utils/__tests__/api-requester.test.ts +3 -4
- package/src/utils/__tests__/sdp.test.ts +16 -30
- package/src/utils/api-requester.ts +1 -4
- package/src/utils/sdp.ts +38 -17
- package/src/web-rtc-client.ts +196 -234
- package/src/websocket-client.ts +2 -3
- package/lib/.DS_Store +0 -0
package/esm/websocket-client.js
CHANGED
|
@@ -197,10 +197,9 @@ class WebSocketClient extends Emitter {
|
|
|
197
197
|
default:
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
this.socket.onerror = event => {
|
|
200
|
+
this.socket.onerror = (event) => {
|
|
201
201
|
logger.info('Wazo WS error', {
|
|
202
202
|
message: event.message,
|
|
203
|
-
// @ts-ignore
|
|
204
203
|
code: event.code,
|
|
205
204
|
readyState: event.target.readyState,
|
|
206
205
|
});
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/index');
|
|
@@ -88,7 +88,6 @@ client.setToken(token);
|
|
|
88
88
|
describe('With correct API results', () => {
|
|
89
89
|
beforeEach(() => {
|
|
90
90
|
jest.resetModules();
|
|
91
|
-
// @ts-expect-error
|
|
92
91
|
global.fetch = jest.fn(() => Promise.resolve(mockedJson));
|
|
93
92
|
});
|
|
94
93
|
describe('logIn test', () => {
|
|
@@ -101,13 +100,11 @@ describe('With correct API results', () => {
|
|
|
101
100
|
Authorization: `Basic ${js_base64_1.Base64.encode(`${username}:${password}`)}`,
|
|
102
101
|
'Content-Type': 'application/json',
|
|
103
102
|
};
|
|
104
|
-
// @ts-expect-error
|
|
105
103
|
const result = yield client.auth.logIn({
|
|
106
104
|
username,
|
|
107
105
|
password,
|
|
108
106
|
});
|
|
109
107
|
expect(result).toBeInstanceOf(Session_1.default);
|
|
110
|
-
// @ts-expect-error
|
|
111
108
|
expect(result.token).toBe(1);
|
|
112
109
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token`, {
|
|
113
110
|
method: 'post',
|
|
@@ -121,7 +118,6 @@ describe('With correct API results', () => {
|
|
|
121
118
|
describe('logOut test', () => {
|
|
122
119
|
it('should delete the specified token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
120
|
const oldToken = 123;
|
|
124
|
-
// @ts-expect-error
|
|
125
121
|
yield client.auth.logOut(oldToken);
|
|
126
122
|
expect(global.fetch).toBeCalledWith(`https://${server}/api/auth/${authVersion}/token/${oldToken}`, {
|
|
127
123
|
method: 'delete',
|
|
@@ -136,7 +132,6 @@ describe('With correct API results', () => {
|
|
|
136
132
|
describe('With unAuthorized API results', () => {
|
|
137
133
|
beforeEach(() => {
|
|
138
134
|
jest.resetModules();
|
|
139
|
-
// @ts-expect-error
|
|
140
135
|
global.fetch = jest.fn(() => Promise.resolve(mockedUnAuthorized));
|
|
141
136
|
});
|
|
142
137
|
describe('checkLogin test', () => {
|
|
@@ -157,7 +152,6 @@ describe('With unAuthorized API results', () => {
|
|
|
157
152
|
describe('With not found API results', () => {
|
|
158
153
|
beforeEach(() => {
|
|
159
154
|
jest.resetModules();
|
|
160
|
-
// @ts-expect-error
|
|
161
155
|
global.fetch = jest.fn(() => Promise.resolve(mockedNotFound));
|
|
162
156
|
});
|
|
163
157
|
describe('fetchVoicemail test', () => {
|
|
@@ -190,13 +184,11 @@ describe('With not found API results', () => {
|
|
|
190
184
|
describe('With erroneous text API results', () => {
|
|
191
185
|
beforeEach(() => {
|
|
192
186
|
jest.resetModules();
|
|
193
|
-
// @ts-expect-error
|
|
194
187
|
global.fetch = jest.fn(() => Promise.resolve(mockedTextError));
|
|
195
188
|
});
|
|
196
189
|
it('throw an exception when the response is >= 500', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
197
190
|
let error = null;
|
|
198
191
|
try {
|
|
199
|
-
// @ts-expect-error
|
|
200
192
|
yield client.auth.logIn({
|
|
201
193
|
username,
|
|
202
194
|
password,
|
|
@@ -214,13 +206,11 @@ describe('With erroneous text API results', () => {
|
|
|
214
206
|
describe('With erroneous json API results', () => {
|
|
215
207
|
beforeEach(() => {
|
|
216
208
|
jest.resetModules();
|
|
217
|
-
// @ts-expect-error
|
|
218
209
|
global.fetch = jest.fn(() => Promise.resolve(mockedJsonError));
|
|
219
210
|
});
|
|
220
211
|
it('throw an exception when the response is >= 500', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
221
212
|
let error = null;
|
|
222
213
|
try {
|
|
223
|
-
// @ts-expect-error
|
|
224
214
|
yield client.auth.logIn({
|
|
225
215
|
username,
|
|
226
216
|
password,
|
|
@@ -20,18 +20,15 @@ jest.mock('sip.js/lib/api/user-agent', () => {
|
|
|
20
20
|
start: () => { },
|
|
21
21
|
UserAgent: (_a = class UserAgent {
|
|
22
22
|
constructor() {
|
|
23
|
-
// @ts-ignore
|
|
24
23
|
this.start = () => { };
|
|
25
24
|
this.transport = {};
|
|
26
25
|
}
|
|
27
26
|
},
|
|
28
|
-
|
|
29
|
-
_a.makeURI = () => { },
|
|
27
|
+
_a.makeURI = () => null,
|
|
30
28
|
_a),
|
|
31
29
|
});
|
|
32
30
|
});
|
|
33
|
-
|
|
34
|
-
const client = new web_rtc_client_1.default({});
|
|
31
|
+
const client = new web_rtc_client_1.default({}, null, undefined);
|
|
35
32
|
describe('WebRTC client', () => {
|
|
36
33
|
it('should compute muted/unmuted state', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
34
|
const mutedSession = {
|
|
@@ -80,13 +77,9 @@ describe('WebRTC client', () => {
|
|
|
80
77
|
},
|
|
81
78
|
},
|
|
82
79
|
};
|
|
83
|
-
// @ts-expect-error
|
|
84
80
|
expect(client.isAudioMuted(mutedSession)).toBeTruthy();
|
|
85
|
-
// @ts-expect-error
|
|
86
81
|
expect(client.isAudioMuted(oldKindMuted)).toBeTruthy();
|
|
87
|
-
// @ts-expect-error
|
|
88
82
|
expect(client.isAudioMuted(unMutedSession)).toBeFalsy();
|
|
89
|
-
// @ts-expect-error
|
|
90
83
|
expect(client.isAudioMuted(oldKindUnmuted)).toBeFalsy();
|
|
91
84
|
}));
|
|
92
85
|
});
|
|
@@ -146,26 +139,20 @@ describe('changeAudioInputDevice', () => {
|
|
|
146
139
|
},
|
|
147
140
|
});
|
|
148
141
|
it('should change the audio input track if the provided id is different', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
149
|
-
// @ts-expect-error
|
|
150
142
|
client.setMediaConstraints(constraints);
|
|
151
143
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
152
|
-
// @ts-expect-error
|
|
153
144
|
const result = yield client.changeAudioInputDevice(deviceId, session);
|
|
154
145
|
expect(result).toBeTruthy();
|
|
155
146
|
}));
|
|
156
147
|
it('should NOT change the audio input track if the provided id is the same', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
157
|
-
// @ts-expect-error
|
|
158
148
|
client.setMediaConstraints(constraints);
|
|
159
149
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
160
|
-
// @ts-expect-error
|
|
161
150
|
const result = yield client.changeAudioInputDevice(defaultId, session);
|
|
162
151
|
expect(result).toBeFalsy();
|
|
163
152
|
}));
|
|
164
153
|
it('should change the audio input track if the provided id is the same and force param is TRUE', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
-
// @ts-expect-error
|
|
166
154
|
client.setMediaConstraints(constraints);
|
|
167
155
|
expect(client.getAudioDeviceId()).toBe(defaultId);
|
|
168
|
-
// @ts-expect-error
|
|
169
156
|
const result = yield client.changeAudioInputDevice(defaultId, session, true);
|
|
170
157
|
expect(result).toBeTruthy();
|
|
171
158
|
}));
|
package/lib/api/chatd.js
CHANGED
|
@@ -39,7 +39,6 @@ exports.default = ((client, baseUrl) => ({
|
|
|
39
39
|
if (uuids.length > MAX_PRESENCE_FETCHED) {
|
|
40
40
|
const requests = uuids.reduce((acc, _, i) => {
|
|
41
41
|
if (i % MAX_PRESENCE_FETCHED === 0) {
|
|
42
|
-
// @ts-ignore
|
|
43
42
|
acc.push(this.getMultipleLineState(uuids.slice(i, i + MAX_PRESENCE_FETCHED)));
|
|
44
43
|
}
|
|
45
44
|
return acc;
|
package/lib/api/dird.js
CHANGED
|
@@ -5,14 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsonToGraphQLQuery_1 = require("json-to-graphql-query/lib/jsonToGraphQLQuery");
|
|
7
7
|
const api_requester_1 = __importDefault(require("../utils/api-requester"));
|
|
8
|
-
const
|
|
8
|
+
const index_1 = require("../index");
|
|
9
9
|
const getContactPayload = (contact) => ({
|
|
10
10
|
email: contact.email,
|
|
11
|
-
// @ts-ignore
|
|
12
11
|
firstname: contact.firstName ? contact.firstName : '',
|
|
13
|
-
// @ts-ignore
|
|
14
12
|
lastname: contact.lastName ? contact.lastName : '',
|
|
15
|
-
// @ts-ignore
|
|
16
13
|
number: contact.phoneNumber ? contact.phoneNumber : '',
|
|
17
14
|
entreprise: contact.entreprise ? contact.entreprise : '',
|
|
18
15
|
birthday: contact.birthday ? contact.birthday : '',
|
|
@@ -22,20 +19,20 @@ const getContactPayload = (contact) => ({
|
|
|
22
19
|
exports.default = ((client, baseUrl) => ({
|
|
23
20
|
search: (context, term, offset = 0, limit = null) => client.get(`${baseUrl}/directories/lookup/${context}`, {
|
|
24
21
|
term,
|
|
25
|
-
}).then((response) =>
|
|
26
|
-
listPersonalContacts: (queryParams = null) => client.get(`${baseUrl}/personal`, queryParams).then((response) =>
|
|
27
|
-
fetchPersonalContact: (contactUuid) => client.get(`${baseUrl}/personal/${contactUuid}`).then(
|
|
28
|
-
addContact: (contact) => client.post(`${baseUrl}/personal`, getContactPayload(contact)).then(
|
|
29
|
-
editContact: (contact) => client.put(`${baseUrl}/personal/${contact.sourceId || contact.id || ''}`, getContactPayload(contact)).then(
|
|
22
|
+
}).then((response) => index_1.Contact.parseMany(response, offset, limit)),
|
|
23
|
+
listPersonalContacts: (queryParams = null) => client.get(`${baseUrl}/personal`, queryParams).then((response) => index_1.Contact.parseManyPersonal(response.items)),
|
|
24
|
+
fetchPersonalContact: (contactUuid) => client.get(`${baseUrl}/personal/${contactUuid}`).then(index_1.Contact.parsePersonal),
|
|
25
|
+
addContact: (contact) => client.post(`${baseUrl}/personal`, getContactPayload(contact)).then(index_1.Contact.parsePersonal),
|
|
26
|
+
editContact: (contact) => client.put(`${baseUrl}/personal/${contact.sourceId || contact.id || ''}`, getContactPayload(contact)).then(index_1.Contact.parsePersonal),
|
|
30
27
|
importContacts: (csv) => {
|
|
31
28
|
const headers = {
|
|
32
29
|
'Content-Type': 'text/csv; charset=utf-8',
|
|
33
30
|
'X-Auth-Token': client.token,
|
|
34
31
|
};
|
|
35
|
-
return client.post(`${baseUrl}/personal/import`, csv, headers).then((result) =>
|
|
32
|
+
return client.post(`${baseUrl}/personal/import`, csv, headers).then((result) => index_1.Contact.parseManyPersonal(result.created));
|
|
36
33
|
},
|
|
37
34
|
deleteContact: (contactUuid) => client.delete(`${baseUrl}/personal/${contactUuid}`),
|
|
38
|
-
listFavorites: (context) => client.get(`${baseUrl}/directories/favorites/${context}`).then(
|
|
35
|
+
listFavorites: (context) => client.get(`${baseUrl}/directories/favorites/${context}`).then(index_1.Contact.parseMany),
|
|
39
36
|
markAsFavorite: (source, sourceId) => {
|
|
40
37
|
const url = `${baseUrl}/directories/favorites/${source}/${sourceId}`;
|
|
41
38
|
return client.put(url, null, null, api_requester_1.default.successResponseParser);
|
|
@@ -46,9 +43,9 @@ exports.default = ((client, baseUrl) => ({
|
|
|
46
43
|
}),
|
|
47
44
|
fetchOffice365Contacts: (source, queryParams = null) => {
|
|
48
45
|
if (!source) {
|
|
49
|
-
return
|
|
46
|
+
return Promise.resolve([]);
|
|
50
47
|
}
|
|
51
|
-
return client.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams).then((response) =>
|
|
48
|
+
return client.get(`${baseUrl}/backends/office365/sources/${source.uuid}/contacts`, queryParams).then((response) => index_1.Contact.parseManyOffice365(response.items, source));
|
|
52
49
|
},
|
|
53
50
|
fetchWazoSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
54
51
|
backend: 'wazo',
|
|
@@ -56,34 +53,34 @@ exports.default = ((client, baseUrl) => ({
|
|
|
56
53
|
// Can be used with `queryParams = { uuid: uuid1, uuid2 }` to fetch multiple contacts
|
|
57
54
|
fetchWazoContacts: (source, queryParams = null) => {
|
|
58
55
|
if (!source) {
|
|
59
|
-
return
|
|
56
|
+
return Promise.resolve([]);
|
|
60
57
|
}
|
|
61
|
-
return client.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams).then((response) =>
|
|
58
|
+
return client.get(`${baseUrl}/backends/wazo/sources/${source.uuid}/contacts`, queryParams).then((response) => index_1.Contact.parseManyWazo(response.items, source));
|
|
62
59
|
},
|
|
63
60
|
fetchGoogleSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
64
61
|
backend: 'google',
|
|
65
62
|
}),
|
|
66
63
|
fetchGoogleContacts: (source, queryParams = null) => {
|
|
67
64
|
if (!source) {
|
|
68
|
-
return
|
|
65
|
+
return Promise.resolve([]);
|
|
69
66
|
}
|
|
70
|
-
return client.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams).then((response) =>
|
|
67
|
+
return client.get(`${baseUrl}/backends/google/sources/${source.uuid}/contacts`, queryParams).then((response) => index_1.Contact.parseManyGoogle(response.items, source));
|
|
71
68
|
},
|
|
72
69
|
fetchConferenceSource: (context) => client.get(`${baseUrl}/directories/${context}/sources`, {
|
|
73
70
|
backend: 'conference',
|
|
74
71
|
}),
|
|
75
72
|
fetchSourcesFor: (context, backend) => client.get(`${baseUrl}/directories/${context}/sources`, { backend }),
|
|
76
|
-
fetchPhonebookContacts: (source, params
|
|
73
|
+
fetchPhonebookContacts: (source, params) => {
|
|
77
74
|
if (!source) {
|
|
78
|
-
return
|
|
75
|
+
return Promise.resolve({ items: [], total: 0 });
|
|
79
76
|
}
|
|
80
77
|
return client.get(`${baseUrl}/backends/phonebook/sources/${source.uuid}/contacts`, params);
|
|
81
78
|
},
|
|
82
79
|
fetchConferenceContacts: (source) => {
|
|
83
80
|
if (!source) {
|
|
84
|
-
return
|
|
81
|
+
return Promise.resolve([]);
|
|
85
82
|
}
|
|
86
|
-
return client.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`).then((response) =>
|
|
83
|
+
return client.get(`${baseUrl}/backends/conference/sources/${source.uuid}/contacts`).then((response) => index_1.Contact.parseManyConference(response.items, source));
|
|
87
84
|
},
|
|
88
85
|
// Graphql
|
|
89
86
|
findMultipleContactsByNumber: (numbers, fields) => {
|
|
@@ -113,6 +110,6 @@ exports.default = ((client, baseUrl) => ({
|
|
|
113
110
|
});
|
|
114
111
|
return client.post(`${baseUrl}/graphql`, {
|
|
115
112
|
query: `{${query}}`,
|
|
116
|
-
}).then(
|
|
113
|
+
}).then(index_1.Contact.manyGraphQlWithNumbersParser(numbers));
|
|
117
114
|
},
|
|
118
115
|
}));
|
|
@@ -39,7 +39,7 @@ exports.default = {
|
|
|
39
39
|
}))), config.iceServers);
|
|
40
40
|
}
|
|
41
41
|
if (externalAppConfig && externalAppConfig.turn_servers) {
|
|
42
|
-
config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...config.iceServers];
|
|
42
|
+
config.iceServers = [...JSON.parse(externalAppConfig.turn_servers), ...(config.iceServers || [])];
|
|
43
43
|
// Force to use TURN when defined in config
|
|
44
44
|
config.iceTransportPolicy = 'relay';
|
|
45
45
|
}
|
|
@@ -59,8 +59,7 @@ exports.default = {
|
|
|
59
59
|
return reject(new Error('No `srflx` or `relay` found in candidate. Please consider using a TURN server.'));
|
|
60
60
|
}
|
|
61
61
|
if (ips.every(checkIsIPV4)) {
|
|
62
|
-
|
|
63
|
-
resolve();
|
|
62
|
+
resolve(null);
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
65
|
const nonIPV4 = ips.find(ip => !checkIsIPV4(ip));
|
|
@@ -38,16 +38,19 @@ exports.default = {
|
|
|
38
38
|
};
|
|
39
39
|
timeout = setTimeout(onEnded, timeoutDuration);
|
|
40
40
|
pc.createDataChannel('wazo-check-nat');
|
|
41
|
-
pc.onicecandidate = e => {
|
|
41
|
+
pc.onicecandidate = (e) => {
|
|
42
42
|
nbCandidates++;
|
|
43
43
|
if (e.candidate) {
|
|
44
44
|
rawCandidates.push(e.candidate.candidate);
|
|
45
45
|
}
|
|
46
46
|
if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
|
|
47
47
|
const cand = (0, webrtc_1.parseCandidate)(e.candidate.candidate);
|
|
48
|
-
if (
|
|
49
|
-
candidates[cand.relatedPort]
|
|
50
|
-
|
|
48
|
+
if (cand.relatedPort) {
|
|
49
|
+
if (!candidates[cand.relatedPort]) {
|
|
50
|
+
candidates[cand.relatedPort] = [];
|
|
51
|
+
}
|
|
52
|
+
candidates[cand.relatedPort].push(cand.port);
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
else if (!e.candidate) {
|
|
53
56
|
onEnded();
|
|
@@ -31,7 +31,7 @@ class AdHocAPIConference {
|
|
|
31
31
|
start() {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
this.started = true;
|
|
34
|
-
// @ts-ignore
|
|
34
|
+
// @ts-ignore: date / number
|
|
35
35
|
this.answerTime = Object.values(this.participants).length ? Object.values(this.participants)[0].answerTime : null;
|
|
36
36
|
const participantIds = Object.keys(this.participants);
|
|
37
37
|
const conference = yield (0, getApiClient_1.default)().calld.createAdHocConference(this.host.callId, participantIds);
|
package/lib/domain/CallLog.js
CHANGED
|
@@ -47,7 +47,7 @@ class CallLog {
|
|
|
47
47
|
static parseNew(plain, session) {
|
|
48
48
|
const callLog = CallLog.parse(plain);
|
|
49
49
|
// @TODO: FIXME add verification declined vs missed call
|
|
50
|
-
callLog.newMissedCall = session && session.hasExtension(plain.requested_extension || plain.destination_extension) && !plain.answered;
|
|
50
|
+
callLog.newMissedCall = session && session.hasExtension((plain.requested_extension || plain.destination_extension)) && !plain.answered;
|
|
51
51
|
return callLog;
|
|
52
52
|
}
|
|
53
53
|
static newFrom(profile) {
|
package/lib/domain/Contact.js
CHANGED
|
@@ -380,7 +380,7 @@ class Contact {
|
|
|
380
380
|
}
|
|
381
381
|
merge(old) {
|
|
382
382
|
Object.keys(old).filter(key => key !== 'lineState').forEach(key => {
|
|
383
|
-
// @ts-ignore
|
|
383
|
+
// @ts-ignore: keys
|
|
384
384
|
this[key] = old[key] || this[key];
|
|
385
385
|
});
|
|
386
386
|
if (old.lineState) {
|
|
@@ -419,4 +419,5 @@ class Contact {
|
|
|
419
419
|
};
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
+
Contact.BACKEND = exports.BACKEND;
|
|
422
423
|
exports.default = Contact;
|
|
@@ -36,4 +36,10 @@ class MeetingAuthorization {
|
|
|
36
36
|
return items.map(MeetingAuthorization.parse);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
MeetingAuthorization.PENDING = exports.PENDING;
|
|
40
|
+
MeetingAuthorization.ACCEPTED = exports.ACCEPTED;
|
|
41
|
+
MeetingAuthorization.REJECTED = exports.REJECTED;
|
|
42
|
+
MeetingAuthorization.POST_PROCESSING = exports.POST_PROCESSING;
|
|
43
|
+
MeetingAuthorization.POST_PROCESSED_SUCCESS = exports.POST_PROCESSED_SUCCESS;
|
|
44
|
+
MeetingAuthorization.POST_PROCESSED_ERROR = exports.POST_PROCESSED_ERROR;
|
|
39
45
|
exports.default = MeetingAuthorization;
|
|
@@ -24,6 +24,7 @@ const logger = IssueReporter_1.default ? IssueReporter_1.default.loggerFor('cti-
|
|
|
24
24
|
class CTIPhone extends Emitter_1.default {
|
|
25
25
|
constructor(session, isMobile = false, callbackAllLines = false) {
|
|
26
26
|
super();
|
|
27
|
+
this.client = null;
|
|
27
28
|
logger.info('CTI Phone created');
|
|
28
29
|
this.session = session;
|
|
29
30
|
this.isMobile = isMobile;
|
|
@@ -318,5 +319,6 @@ class CTIPhone extends Emitter_1.default {
|
|
|
318
319
|
}
|
|
319
320
|
useLocalVideoElement() { }
|
|
320
321
|
setMediaConstraints() { }
|
|
322
|
+
register() { return Promise.resolve(null); }
|
|
321
323
|
}
|
|
322
324
|
exports.default = CTIPhone;
|
|
@@ -245,7 +245,6 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
245
245
|
const shouldScreenShare = constraints && !!constraints.screen;
|
|
246
246
|
const desktop = constraints && constraints.desktop;
|
|
247
247
|
const options = sipSession.sessionDescriptionHandlerOptionsReInvite;
|
|
248
|
-
// @ts-ignore
|
|
249
248
|
const wasAudioOnly = options === null || options === void 0 ? void 0 : options.audioOnly;
|
|
250
249
|
const newStream = yield this.client.upgradeToVideo(sipSession, constraints, isConference);
|
|
251
250
|
if (callSession) {
|
|
@@ -343,9 +342,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
343
342
|
return;
|
|
344
343
|
}
|
|
345
344
|
// Video events
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
peerConnection
|
|
345
|
+
const sdh = sipSession.sessionDescriptionHandler;
|
|
346
|
+
const peerConnection = sdh.peerConnection;
|
|
347
|
+
if (!peerConnection) {
|
|
348
|
+
logger.info('null peer connection');
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
349
351
|
peerConnection.ontrack = (rawEvent) => {
|
|
350
352
|
const event = rawEvent;
|
|
351
353
|
const [stream] = event.streams;
|
|
@@ -609,7 +611,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
609
611
|
if (callSession.getId() in this.ignoredSessions) {
|
|
610
612
|
return false;
|
|
611
613
|
}
|
|
612
|
-
// @ts-ignore
|
|
614
|
+
// @ts-ignore: does not exist
|
|
613
615
|
if (!sipSession.isCanceled) {
|
|
614
616
|
setTimeout(() => {
|
|
615
617
|
this.eventEmitter.emit(exports.ON_PLAY_HANGUP_SOUND, this.audioOutputDeviceId, this.audioOutputVolume, callSession);
|
|
@@ -635,9 +637,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
635
637
|
if (!sipSession) {
|
|
636
638
|
return false;
|
|
637
639
|
}
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
peerConnection, } = sipSession.sessionDescriptionHandler;
|
|
640
|
+
const sdh = sipSession.sessionDescriptionHandler;
|
|
641
|
+
const peerConnection = sdh.peerConnection;
|
|
641
642
|
const remoteStream = peerConnection.getRemoteStreams().find((stream) => !!stream.getVideoTracks().length);
|
|
642
643
|
return remoteStream && remoteStream.getVideoTracks().some(track => !track.muted);
|
|
643
644
|
}
|
|
@@ -1006,9 +1007,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1006
1007
|
this.currentCallSession = callSession;
|
|
1007
1008
|
this.eventEmitter.emit(exports.ON_CALL_OUTGOING, callSession);
|
|
1008
1009
|
// If an invite promise exists, catch exceptions on it to trigger error like OverConstraintsError.
|
|
1009
|
-
// @ts-ignore
|
|
1010
|
+
// @ts-ignore: does not exist
|
|
1010
1011
|
if (sipSession.invitePromise) {
|
|
1011
|
-
// @ts-ignore
|
|
1012
|
+
// @ts-ignore: does not exist
|
|
1012
1013
|
sipSession.invitePromise.catch(error => {
|
|
1013
1014
|
this.eventEmitter.emit(exports.ON_CALL_ERROR, error, callSession);
|
|
1014
1015
|
});
|
|
@@ -1095,12 +1096,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1095
1096
|
return sipSession ? this.client.stopNetworkMonitoring(sipSession) : null;
|
|
1096
1097
|
}
|
|
1097
1098
|
forceCancel(sipSession) {
|
|
1098
|
-
// @ts-ignore
|
|
1099
|
+
// @ts-ignore: private
|
|
1099
1100
|
if (!sipSession || !sipSession.outgoingInviteRequest) {
|
|
1100
1101
|
return;
|
|
1101
1102
|
}
|
|
1102
1103
|
try {
|
|
1103
|
-
// @ts-ignore
|
|
1104
|
+
// @ts-ignore: private
|
|
1104
1105
|
sipSession.outgoingInviteRequest.cancel();
|
|
1105
1106
|
}
|
|
1106
1107
|
catch (e) {
|
|
@@ -1317,7 +1318,6 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1317
1318
|
// send a reinvite to renegociate ICE with new IP
|
|
1318
1319
|
if (this.shouldSendReinvite && this.currentSipSession && this.currentSipSession.state === session_state_1.SessionState.Established) {
|
|
1319
1320
|
this.shouldSendReinvite = false;
|
|
1320
|
-
// @ts-ignore
|
|
1321
1321
|
const pc = (_b = (_a = this.currentSipSession) === null || _a === void 0 ? void 0 : _a.sessionDescriptionHandler) === null || _b === void 0 ? void 0 : _b.peerConnection;
|
|
1322
1322
|
const isConference = pc ? pc.sfu : false;
|
|
1323
1323
|
const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
|
|
@@ -1400,14 +1400,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
_onMessage(message) {
|
|
1403
|
-
// @ts-ignore
|
|
1404
1403
|
if (!message || message.method !== 'MESSAGE') {
|
|
1405
1404
|
return;
|
|
1406
1405
|
}
|
|
1407
1406
|
let body;
|
|
1408
1407
|
try {
|
|
1409
|
-
|
|
1410
|
-
body = JSON.parse(message.body);
|
|
1408
|
+
body = JSON.parse(message.body || '');
|
|
1411
1409
|
}
|
|
1412
1410
|
catch (e) {
|
|
1413
1411
|
return;
|
|
@@ -1468,13 +1466,13 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1468
1466
|
_createCallSession(sipSession, fromSession, extra = {}) {
|
|
1469
1467
|
// eslint-disable-next-line
|
|
1470
1468
|
const identity = sipSession ? sipSession.remoteIdentity || sipSession.assertedIdentity : null;
|
|
1471
|
-
// @ts-ignore
|
|
1469
|
+
// @ts-ignore: private
|
|
1472
1470
|
const number = identity ? identity.uri._normal.user : null;
|
|
1473
1471
|
const { state, } = sipSession || {};
|
|
1474
1472
|
const sessionId = this.getSipSessionId(sipSession);
|
|
1475
1473
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1476
1474
|
const callSession = new CallSession_1.default(Object.assign({ callId: fromSession && fromSession.callId, sipCallId: sessionId, sipStatus: state, displayName: identity ? identity.displayName || number : number,
|
|
1477
|
-
// @ts-ignore:
|
|
1475
|
+
// @ts-ignore: date / number
|
|
1478
1476
|
startTime: fromSession ? fromSession.startTime : new Date(), creationTime: fromSession ? fromSession.creationTime : null, answerTime: fromSession ? fromSession.answerTime : null, endTime: fromSession ? fromSession.endTime : null, answered: state === session_state_1.SessionState.Established, paused: this.client.isCallHeld(sipSession), isCaller: fromSession ? fromSession.isCaller : 'incoming' in extra ? !extra.incoming : false, cameraEnabled: fromSession ? fromSession.isCameraEnabled() : this.client.hasVideo(sessionId), number, ringing: false, muted: fromSession ? fromSession.isMuted() : this.client.isAudioMuted(sipSession), videoMuted: fromSession ? fromSession.isVideoMuted() : false, recording: fromSession ? fromSession.isRecording() : false, recordingPaused: false, sipSession, conference: !!fromSession && fromSession.isConference() }, extra));
|
|
1479
1477
|
this.callSessions[sessionId] = callSession;
|
|
1480
1478
|
return callSession;
|
package/lib/domain/Session.js
CHANGED
|
@@ -21,7 +21,7 @@ class Session {
|
|
|
21
21
|
if (token) {
|
|
22
22
|
const isValid = jws.JWS.verifyJWT(token, swarmKey, {
|
|
23
23
|
alg: ['RS256'],
|
|
24
|
-
// @ts-ignore
|
|
24
|
+
// @ts-ignore: date / number
|
|
25
25
|
verifyAt: new Date(),
|
|
26
26
|
});
|
|
27
27
|
if (isValid) {
|
|
@@ -126,7 +126,7 @@ class Session {
|
|
|
126
126
|
return line && Array.isArray(line.extensions) && line.extensions.length > 0 ? line.extensions[0].context : 'default';
|
|
127
127
|
}
|
|
128
128
|
hasEngineVersionGte(version) {
|
|
129
|
-
return this.engineVersion && (0, compare_version_1.default)(String(this.engineVersion), String(version)) >= 0;
|
|
129
|
+
return !!this.engineVersion && (0, compare_version_1.default)(String(this.engineVersion), String(version)) >= 0;
|
|
130
130
|
}
|
|
131
131
|
primaryNumber() {
|
|
132
132
|
const line = this.primaryLine();
|
|
@@ -31,14 +31,12 @@ Object.keys(fieldMap).forEach((field) => {
|
|
|
31
31
|
});
|
|
32
32
|
describe('Call Center Agent domain', () => {
|
|
33
33
|
it('should keep its values', () => {
|
|
34
|
-
// @ts-expect-error
|
|
35
34
|
const agent = new Agent_1.default(formatted);
|
|
36
35
|
expect(agent).toBeInstanceOf(Agent_1.default);
|
|
37
36
|
Object.keys(fieldMap).map(key => expect(agent[key]).toBe(formatted[key]));
|
|
38
37
|
});
|
|
39
38
|
it('can parse a plain call center agent to domain', () => {
|
|
40
39
|
const agent = Agent_1.default.parse(plain);
|
|
41
|
-
// @ts-expect-error
|
|
42
40
|
expect(agent).toEqual(new Agent_1.default(formatted));
|
|
43
41
|
});
|
|
44
42
|
});
|
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// @ts-nocheck
|
|
7
6
|
const Call_1 = __importDefault(require("../Call"));
|
|
8
7
|
describe('Call domain', () => {
|
|
9
8
|
it('can return the elapsed time since its creation in seconds', () => {
|
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// @ts-nocheck
|
|
7
6
|
const CallSession_1 = __importDefault(require("../CallSession"));
|
|
8
|
-
const stringify = cs => JSON.parse(JSON.stringify(cs));
|
|
7
|
+
const stringify = (cs) => JSON.parse(JSON.stringify(cs));
|
|
9
8
|
describe('CallSession domain', () => {
|
|
10
9
|
it('should update from another CallSession without data loss', () => {
|
|
11
10
|
const callSession = new CallSession_1.default({
|
|
@@ -305,13 +305,11 @@ describe('Contact domain', () => {
|
|
|
305
305
|
const noBirthdayContact = new Contact_1.default({
|
|
306
306
|
uuid: 'uuid-12345',
|
|
307
307
|
lastActivity: 'yesterday',
|
|
308
|
-
|
|
309
|
-
birthday: null,
|
|
308
|
+
birthday: undefined,
|
|
310
309
|
});
|
|
311
310
|
const noLastActivityContact = new Contact_1.default({
|
|
312
311
|
uuid: 'uuid-12345',
|
|
313
|
-
|
|
314
|
-
lastActivity: null,
|
|
312
|
+
lastActivity: undefined,
|
|
315
313
|
birthday: 'tomorrow',
|
|
316
314
|
});
|
|
317
315
|
const result = noBirthdayContact.merge(noLastActivityContact);
|
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
// @ts-nocheck
|
|
16
15
|
const CallSession_1 = __importDefault(require("../CallSession"));
|
|
17
16
|
const IndirectTransfer_1 = __importDefault(require("../IndirectTransfer"));
|
|
18
17
|
describe('Indirect transfer', () => {
|
|
@@ -26,7 +26,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
// @ts-nocheck
|
|
30
29
|
const Profile_1 = __importDefault(require("../Profile"));
|
|
31
30
|
const Line_1 = __importDefault(require("../Line"));
|
|
32
31
|
const ForwardOption_1 = __importStar(require("../ForwardOption"));
|