@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/lib/web-rtc-client.js
CHANGED
|
@@ -194,7 +194,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
194
194
|
method: 'delegate.onInvite',
|
|
195
195
|
clientId: this.clientId,
|
|
196
196
|
id: invitation.id,
|
|
197
|
-
// @ts-ignore
|
|
198
197
|
remoteURI: invitation.remoteURI,
|
|
199
198
|
});
|
|
200
199
|
this._setupSession(invitation);
|
|
@@ -212,6 +211,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
212
211
|
ua.transport.onMessage = (rawMessage) => {
|
|
213
212
|
const message = parser_1.Parser.parseMessage(rawMessage, ua.transport.logger);
|
|
214
213
|
// We have to re-sent the message to the UA ...
|
|
214
|
+
// @ts-ignore: private
|
|
215
215
|
ua.onTransportMessage(rawMessage);
|
|
216
216
|
// And now do what we want with the message
|
|
217
217
|
this.eventEmitter.emit(MESSAGE, message);
|
|
@@ -239,9 +239,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
239
239
|
var _a;
|
|
240
240
|
logger.info('sdk webrtc connected', { method: 'delegate.onConnect', clientId: this.clientId });
|
|
241
241
|
this.eventEmitter.emit(CONNECTED);
|
|
242
|
-
// @ts-ignore
|
|
242
|
+
// @ts-ignore: private
|
|
243
243
|
if (!this.isRegistered() && ((_a = this.registerer) === null || _a === void 0 ? void 0 : _a.waiting)) {
|
|
244
|
-
// @ts-ignore
|
|
244
|
+
// @ts-ignore: private
|
|
245
245
|
this.registerer.waitingToggle(false);
|
|
246
246
|
}
|
|
247
247
|
return this.register();
|
|
@@ -255,9 +255,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
255
255
|
this.eventEmitter.emit(DISCONNECTED, error);
|
|
256
256
|
if (this.isRegistered()) {
|
|
257
257
|
yield this.unregister();
|
|
258
|
-
// @ts-ignore
|
|
258
|
+
// @ts-ignore: private
|
|
259
259
|
if ((_a = this.registerer) === null || _a === void 0 ? void 0 : _a.waiting) {
|
|
260
|
-
// @ts-ignore
|
|
260
|
+
// @ts-ignore: private
|
|
261
261
|
this.registerer.waitingToggle(false);
|
|
262
262
|
}
|
|
263
263
|
this.eventEmitter.emit(UNREGISTERED);
|
|
@@ -273,7 +273,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
273
273
|
registered: this.isRegistered(),
|
|
274
274
|
connectionPromise: !!this.connectionPromise,
|
|
275
275
|
registerer: !!this.registerer,
|
|
276
|
-
// @ts-ignore
|
|
276
|
+
// @ts-ignore: private
|
|
277
277
|
waiting: this.registerer && this.registerer.waiting,
|
|
278
278
|
tries,
|
|
279
279
|
skipRegister: this.skipRegister,
|
|
@@ -292,7 +292,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
292
292
|
logger.info('sdk webrtc registering aborted, already registered or no UA can be created');
|
|
293
293
|
return Promise.resolve();
|
|
294
294
|
}
|
|
295
|
-
// @ts-ignore
|
|
295
|
+
// @ts-ignore: private
|
|
296
296
|
if (this.connectionPromise || ((_a = this.registerer) === null || _a === void 0 ? void 0 : _a.waiting)) {
|
|
297
297
|
logger.info('sdk webrtc registering aborted due to a registration in progress.', { clientId: this.clientId });
|
|
298
298
|
return Promise.resolve();
|
|
@@ -311,9 +311,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
313
|
this.connectionPromise = null;
|
|
314
|
-
// @ts-ignore
|
|
314
|
+
// @ts-ignore: private
|
|
315
315
|
if (this.registerer && this.registerer.waiting) {
|
|
316
|
-
// @ts-ignore
|
|
316
|
+
// @ts-ignore: private
|
|
317
317
|
this.registerer.waitingToggle(false);
|
|
318
318
|
}
|
|
319
319
|
if (tries <= MAX_REGISTER_TRIES) {
|
|
@@ -366,19 +366,19 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
366
366
|
if (!registerer) {
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
|
-
// @ts-ignore
|
|
369
|
+
// @ts-ignore: private
|
|
370
370
|
const oldWaitingToggle = registerer.waitingToggle.bind(registerer);
|
|
371
|
-
// @ts-ignore
|
|
371
|
+
// @ts-ignore: private
|
|
372
372
|
const oldUnregistered = registerer.unregistered.bind(registerer);
|
|
373
|
-
// @ts-ignore
|
|
373
|
+
// @ts-ignore: private
|
|
374
374
|
registerer.waitingToggle = (waiting) => {
|
|
375
|
-
// @ts-ignore
|
|
375
|
+
// @ts-ignore: private
|
|
376
376
|
if (!registerer || registerer.waiting === waiting) {
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
379
|
oldWaitingToggle(waiting);
|
|
380
380
|
};
|
|
381
|
-
// @ts-ignore
|
|
381
|
+
// @ts-ignore: private
|
|
382
382
|
registerer.unregistered = () => {
|
|
383
383
|
if (!registerer || registerer.state === registerer_state_1.RegistererState.Terminated) {
|
|
384
384
|
return;
|
|
@@ -457,7 +457,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
457
457
|
inviterOptions.sessionDescriptionHandlerModifiersReInvite = [modifiers_1.stripVideo];
|
|
458
458
|
}
|
|
459
459
|
const uri = this._makeURI(number);
|
|
460
|
-
let session;
|
|
460
|
+
let session = null;
|
|
461
461
|
if (uri) {
|
|
462
462
|
session = this.userAgent ? new api_1.Inviter(this.userAgent, uri, inviterOptions) : null;
|
|
463
463
|
}
|
|
@@ -475,23 +475,21 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
475
475
|
requestDelegate: {
|
|
476
476
|
onAccept: (response) => {
|
|
477
477
|
var _a;
|
|
478
|
-
if ((_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection) {
|
|
479
|
-
session.sessionDescriptionHandler.peerConnection.sfu = conference;
|
|
478
|
+
if ((_a = session === null || session === void 0 ? void 0 : session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection) {
|
|
479
|
+
(session === null || session === void 0 ? void 0 : session.sessionDescriptionHandler).peerConnection.sfu = conference;
|
|
480
480
|
}
|
|
481
|
-
// @ts-ignore
|
|
482
481
|
this._onAccepted(session, response.session, true);
|
|
483
482
|
},
|
|
484
|
-
onProgress: payload => {
|
|
483
|
+
onProgress: (payload) => {
|
|
485
484
|
if (payload.message.statusCode === 183) {
|
|
486
|
-
// @ts-ignore
|
|
487
485
|
this._onEarlyProgress(payload.session);
|
|
488
486
|
}
|
|
489
487
|
},
|
|
490
488
|
onReject: (response) => {
|
|
491
489
|
logger.info('on call rejected', {
|
|
492
|
-
id: session.id,
|
|
493
|
-
// @ts-ignore
|
|
494
|
-
fromTag: session.fromTag,
|
|
490
|
+
id: session === null || session === void 0 ? void 0 : session.id,
|
|
491
|
+
// @ts-ignore: fromTag does not exist
|
|
492
|
+
fromTag: session === null || session === void 0 ? void 0 : session.fromTag,
|
|
495
493
|
});
|
|
496
494
|
this._stopSendingStats(session);
|
|
497
495
|
this.stopNetworkMonitoring(session);
|
|
@@ -501,17 +499,19 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
501
499
|
sessionDescriptionHandlerOptions: this.getMediaConfiguration(enableVideo || false, conference),
|
|
502
500
|
};
|
|
503
501
|
if (inviteOptions.sessionDescriptionHandlerOptions) {
|
|
504
|
-
// @ts-ignore
|
|
505
502
|
inviteOptions.sessionDescriptionHandlerOptions.audioOnly = audioOnly;
|
|
506
503
|
}
|
|
507
504
|
inviteOptions.sessionDescriptionHandlerModifiers = [exports.replaceLocalIpModifier];
|
|
508
505
|
if (audioOnly) {
|
|
509
506
|
inviteOptions.sessionDescriptionHandlerModifiers.push(modifiers_1.stripVideo);
|
|
510
507
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
508
|
+
if (session) {
|
|
509
|
+
// Do not await invite here or we'll miss the Establishing state transition
|
|
510
|
+
// @ts-ignore: Property 'invitePromise' does not exist
|
|
511
|
+
session.invitePromise = session.invite(inviteOptions).catch((e) => {
|
|
512
|
+
logger.warn('sdk webrtc creating call, error', e);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
515
|
return session;
|
|
516
516
|
}
|
|
517
517
|
answer(session, enableVideo) {
|
|
@@ -529,7 +529,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
529
529
|
sessionDescriptionHandlerOptions: this.getMediaConfiguration(enableVideo || false),
|
|
530
530
|
};
|
|
531
531
|
return this._accept(session, options).then(() => {
|
|
532
|
-
// @ts-ignore
|
|
532
|
+
// @ts-ignore: private
|
|
533
533
|
if (session.isCanceled) {
|
|
534
534
|
const message = 'accepted a canceled session (or was canceled during the accept phase).';
|
|
535
535
|
logger.error(message, {
|
|
@@ -574,9 +574,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
576
|
getStats(session) {
|
|
577
|
+
var _a;
|
|
577
578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
578
|
-
|
|
579
|
-
const pc = session.sessionDescriptionHandler.peerConnection;
|
|
579
|
+
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
580
580
|
if (!pc) {
|
|
581
581
|
return null;
|
|
582
582
|
}
|
|
@@ -649,13 +649,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
649
649
|
if (this.userAgent) {
|
|
650
650
|
this.userAgent.delegate = undefined;
|
|
651
651
|
}
|
|
652
|
-
// @ts-ignore:
|
|
652
|
+
// @ts-ignore: removeAllListeners does not exist
|
|
653
653
|
this.userAgent.stateChange.removeAllListeners();
|
|
654
654
|
yield this._disconnectTransport(force);
|
|
655
655
|
this._cleanupRegister();
|
|
656
656
|
try {
|
|
657
657
|
// Prevent `Connect aborted.` error when disconnecting
|
|
658
|
-
// @ts-ignore
|
|
659
658
|
this.userAgent.transport.connectReject = () => { };
|
|
660
659
|
// Don't wait here, It can take ~30s to stop ...
|
|
661
660
|
this.userAgent.stop().catch(console.error);
|
|
@@ -671,7 +670,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
671
670
|
if (!session) {
|
|
672
671
|
return null;
|
|
673
672
|
}
|
|
674
|
-
// @ts-ignore
|
|
673
|
+
// @ts-ignore: private
|
|
675
674
|
return session.remoteIdentity.uri._normal.user;
|
|
676
675
|
}
|
|
677
676
|
mute(session) {
|
|
@@ -691,7 +690,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
691
690
|
return false;
|
|
692
691
|
}
|
|
693
692
|
let muted = true;
|
|
694
|
-
// @ts-ignore
|
|
695
693
|
const pc = session.sessionDescriptionHandler.peerConnection;
|
|
696
694
|
if (!pc) {
|
|
697
695
|
return false;
|
|
@@ -736,7 +734,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
736
734
|
logger.info('sdk webrtc hold', {
|
|
737
735
|
sessionId,
|
|
738
736
|
keys: Object.keys(this.heldSessions),
|
|
739
|
-
// @ts-ignore
|
|
737
|
+
// @ts-ignore: private
|
|
740
738
|
pendingReinvite: !!session.pendingReinvite,
|
|
741
739
|
isConference,
|
|
742
740
|
hasVideo,
|
|
@@ -744,7 +742,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
744
742
|
if (sessionId in this.heldSessions) {
|
|
745
743
|
return Promise.resolve();
|
|
746
744
|
}
|
|
747
|
-
// @ts-ignore
|
|
745
|
+
// @ts-ignore: private
|
|
748
746
|
if (session.pendingReinvite) {
|
|
749
747
|
return Promise.resolve();
|
|
750
748
|
}
|
|
@@ -756,7 +754,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
756
754
|
// `sendonly` direction
|
|
757
755
|
this.mute(session);
|
|
758
756
|
session.sessionDescriptionHandlerOptionsReInvite = {
|
|
759
|
-
// @ts-ignore
|
|
760
757
|
hold: true,
|
|
761
758
|
conference: isConference,
|
|
762
759
|
};
|
|
@@ -771,7 +768,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
771
768
|
};
|
|
772
769
|
// Avoid sdh to create a new stream
|
|
773
770
|
if (session.sessionDescriptionHandler) {
|
|
774
|
-
// @ts-ignore
|
|
771
|
+
// @ts-ignore: private
|
|
775
772
|
session.sessionDescriptionHandler.localMediaStreamConstraints = options.constraints;
|
|
776
773
|
}
|
|
777
774
|
// Send re-INVITE
|
|
@@ -785,19 +782,18 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
785
782
|
logger.info('sdk webrtc unhold', {
|
|
786
783
|
sessionId,
|
|
787
784
|
keys: Object.keys(this.heldSessions),
|
|
788
|
-
// @ts-ignore
|
|
785
|
+
// @ts-ignore: private
|
|
789
786
|
pendingReinvite: !!session.pendingReinvite,
|
|
790
787
|
isConference,
|
|
791
788
|
hasVideo,
|
|
792
789
|
});
|
|
793
|
-
// @ts-ignore
|
|
790
|
+
// @ts-ignore: private
|
|
794
791
|
if (session.pendingReinvite) {
|
|
795
792
|
return Promise.resolve();
|
|
796
793
|
}
|
|
797
794
|
this.unmute(session);
|
|
798
795
|
delete this.heldSessions[this.getSipSessionId(session)];
|
|
799
796
|
session.sessionDescriptionHandlerOptionsReInvite = {
|
|
800
|
-
// @ts-ignore
|
|
801
797
|
hold: false,
|
|
802
798
|
conference: isConference,
|
|
803
799
|
};
|
|
@@ -819,14 +815,14 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
819
815
|
}
|
|
820
816
|
// Returns true if a re-INVITE is required
|
|
821
817
|
upgradeToVideo(session, constraints, isConference) {
|
|
818
|
+
var _a, _b;
|
|
822
819
|
return __awaiter(this, void 0, void 0, function* () {
|
|
823
|
-
|
|
824
|
-
const pc = session.sessionDescriptionHandler.peerConnection;
|
|
820
|
+
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
825
821
|
// Check if a video sender already exists
|
|
826
822
|
let videoSender;
|
|
827
823
|
if (isConference) {
|
|
828
824
|
// We search for the last transceiver without `video-` in the mid (video- means remote transceiver)
|
|
829
|
-
const transceivers = pc.getTransceivers();
|
|
825
|
+
const transceivers = (pc === null || pc === void 0 ? void 0 : pc.getTransceivers()) || [];
|
|
830
826
|
const transceiverIdx = (0, array_1.lastIndexOf)(transceivers, transceiver => transceiver.sender.track === null && transceiver.mid && transceiver.mid.indexOf('video') === -1);
|
|
831
827
|
videoSender = transceiverIdx !== -1 ? transceivers[transceiverIdx].sender : null;
|
|
832
828
|
}
|
|
@@ -845,8 +841,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
845
841
|
}
|
|
846
842
|
// Add previous local audio track
|
|
847
843
|
if (constraints && !constraints.audio) {
|
|
848
|
-
|
|
849
|
-
const localVideoStream = session.sessionDescriptionHandler.localMediaStream;
|
|
844
|
+
const localVideoStream = (_b = session.sessionDescriptionHandler) === null || _b === void 0 ? void 0 : _b.localMediaStream;
|
|
850
845
|
const localAudioTrack = localVideoStream.getTracks().find(track => track.kind === 'audio');
|
|
851
846
|
if (localAudioTrack) {
|
|
852
847
|
newStream.addTrack(localAudioTrack);
|
|
@@ -862,13 +857,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
862
857
|
}
|
|
863
858
|
downgradeToAudio(session) {
|
|
864
859
|
// Release local video stream when downgrading to audio
|
|
865
|
-
|
|
866
|
-
const localStream =
|
|
867
|
-
|
|
868
|
-
const pc = session.sessionDescriptionHandler.peerConnection;
|
|
860
|
+
const sessionDescriptionHandler = session.sessionDescriptionHandler;
|
|
861
|
+
const localStream = sessionDescriptionHandler === null || sessionDescriptionHandler === void 0 ? void 0 : sessionDescriptionHandler.localMediaStream;
|
|
862
|
+
const pc = sessionDescriptionHandler === null || sessionDescriptionHandler === void 0 ? void 0 : sessionDescriptionHandler.peerConnection;
|
|
869
863
|
const videoTracks = localStream.getVideoTracks();
|
|
870
864
|
// Remove video senders
|
|
871
|
-
if (pc.getSenders) {
|
|
865
|
+
if (pc === null || pc === void 0 ? void 0 : pc.getSenders) {
|
|
872
866
|
pc.getSenders().filter((sender) => sender.track && sender.track.kind === 'video').forEach((videoSender) => {
|
|
873
867
|
videoSender.replaceTrack(null);
|
|
874
868
|
});
|
|
@@ -883,7 +877,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
883
877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
884
878
|
const video = constraints && constraints.video;
|
|
885
879
|
const { constraints: newConstraints, } = this.getMediaConfiguration(video, conference, constraints);
|
|
886
|
-
let newStream;
|
|
880
|
+
let newStream = null;
|
|
887
881
|
try {
|
|
888
882
|
newStream = yield (0, WazoSessionDescriptionHandler_1.wazoMediaStreamFactory)(newConstraints);
|
|
889
883
|
}
|
|
@@ -892,7 +886,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
892
886
|
if (!newStream) {
|
|
893
887
|
return null;
|
|
894
888
|
}
|
|
895
|
-
// @ts-ignore
|
|
896
889
|
newStream.local = true;
|
|
897
890
|
return newStream;
|
|
898
891
|
});
|
|
@@ -1025,7 +1018,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1025
1018
|
logger.warn('pingServer: null fromURI');
|
|
1026
1019
|
}
|
|
1027
1020
|
getState() {
|
|
1028
|
-
// @ts-ignore
|
|
1021
|
+
// @ts-ignore: something fishy here: `states` content doesn't match UserAgentState at all
|
|
1029
1022
|
return this.userAgent ? states[this.userAgent.state] : user_agent_state_1.UserAgentState.Stopped;
|
|
1030
1023
|
}
|
|
1031
1024
|
getContactIdentifier() {
|
|
@@ -1056,9 +1049,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1056
1049
|
// audioElement is an array of HTMLAudioElements, and HTMLAudioElement inherits the method from HTMLMediaElement
|
|
1057
1050
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement
|
|
1058
1051
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId
|
|
1059
|
-
// @ts-ignore
|
|
1060
1052
|
if (audioElement.setSinkId) {
|
|
1061
|
-
// @ts-ignore
|
|
1062
1053
|
audioElement.setSinkId(id);
|
|
1063
1054
|
}
|
|
1064
1055
|
});
|
|
@@ -1101,8 +1092,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1101
1092
|
}
|
|
1102
1093
|
if (session && navigator.mediaDevices) {
|
|
1103
1094
|
const sdh = session.sessionDescriptionHandler;
|
|
1104
|
-
|
|
1105
|
-
const pc = sdh.peerConnection;
|
|
1095
|
+
const pc = sdh === null || sdh === void 0 ? void 0 : sdh.peerConnection;
|
|
1106
1096
|
const constraints = {
|
|
1107
1097
|
audio: {
|
|
1108
1098
|
deviceId: {
|
|
@@ -1152,7 +1142,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1152
1142
|
return Promise.resolve();
|
|
1153
1143
|
}
|
|
1154
1144
|
const sdh = session.sessionDescriptionHandler;
|
|
1155
|
-
// @ts-ignore
|
|
1156
1145
|
const pc = sdh.peerConnection;
|
|
1157
1146
|
const sessionId = this.getSipSessionId(session);
|
|
1158
1147
|
const localStream = this.getLocalStream(sessionId);
|
|
@@ -1196,18 +1185,18 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1196
1185
|
}));
|
|
1197
1186
|
}
|
|
1198
1187
|
getAudioDeviceId() {
|
|
1199
|
-
|
|
1200
|
-
return this.audio && typeof this.audio === 'object' && 'deviceId' in this.audio ? this.audio.deviceId.exact : undefined;
|
|
1188
|
+
var _a;
|
|
1189
|
+
return this.audio && typeof this.audio === 'object' && 'deviceId' in this.audio ? (_a = this.audio.deviceId) === null || _a === void 0 ? void 0 : _a.exact : undefined;
|
|
1201
1190
|
}
|
|
1202
1191
|
getVideoDeviceId() {
|
|
1203
|
-
|
|
1204
|
-
return this.video && typeof this.video === 'object' && 'deviceId' in this.video ? this.video.deviceId.exact : undefined;
|
|
1192
|
+
var _a;
|
|
1193
|
+
return this.video && typeof this.video === 'object' && 'deviceId' in this.video ? (_a = this.video.deviceId) === null || _a === void 0 ? void 0 : _a.exact : undefined;
|
|
1205
1194
|
}
|
|
1206
1195
|
reinvite(sipSession, newConstraints = null, conference = false, audioOnly = false, iceRestart = false) {
|
|
1207
1196
|
if (!sipSession) {
|
|
1208
1197
|
return Promise.resolve();
|
|
1209
1198
|
}
|
|
1210
|
-
// @ts-ignore
|
|
1199
|
+
// @ts-ignore: private
|
|
1211
1200
|
if (sipSession.pendingReinvite) {
|
|
1212
1201
|
return Promise.resolve();
|
|
1213
1202
|
}
|
|
@@ -1231,9 +1220,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1231
1220
|
const modifiers = sipSession.sessionDescriptionHandlerModifiersReInvite;
|
|
1232
1221
|
sipSession.sessionDescriptionHandlerModifiersReInvite = modifiers.filter(modifier => modifier !== modifiers_1.stripVideo);
|
|
1233
1222
|
}
|
|
1234
|
-
sipSession.sessionDescriptionHandlerOptionsReInvite = Object.assign(Object.assign({}, sipSession.sessionDescriptionHandlerOptionsReInvite), {
|
|
1235
|
-
// @ts-ignore
|
|
1236
|
-
conference,
|
|
1223
|
+
sipSession.sessionDescriptionHandlerOptionsReInvite = Object.assign(Object.assign({}, sipSession.sessionDescriptionHandlerOptionsReInvite), { conference,
|
|
1237
1224
|
audioOnly });
|
|
1238
1225
|
const { constraints, } = this.getMediaConfiguration(shouldDoVideo, conference, newConstraints);
|
|
1239
1226
|
return sipSession.invite({
|
|
@@ -1241,13 +1228,13 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1241
1228
|
onAccept: (response) => {
|
|
1242
1229
|
// Update the SDP body to be able to call sessionWantsToDoVideo correctly in `_setup[Local|Remote]Media`.
|
|
1243
1230
|
// Can't set directly sipSession.body because it's a getter.
|
|
1244
|
-
// @ts-ignore
|
|
1231
|
+
// @ts-ignore: private
|
|
1245
1232
|
if (sipSession instanceof api_1.Inviter && sipSession.outgoingRequestMessage.body) {
|
|
1246
|
-
// @ts-ignore
|
|
1233
|
+
// @ts-ignore: private
|
|
1247
1234
|
sipSession.outgoingRequestMessage.body.body = response.message.body;
|
|
1248
1235
|
}
|
|
1249
1236
|
else if (sipSession instanceof api_1.Invitation) {
|
|
1250
|
-
// @ts-ignore
|
|
1237
|
+
// @ts-ignore: private
|
|
1251
1238
|
sipSession.incomingInviteRequest.message.body = response.message.body;
|
|
1252
1239
|
}
|
|
1253
1240
|
logger.info('on re-INVITE accepted', {
|
|
@@ -1259,7 +1246,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1259
1246
|
if (wasMuted) {
|
|
1260
1247
|
this.mute(sipSession);
|
|
1261
1248
|
}
|
|
1262
|
-
// @ts-ignore
|
|
1263
1249
|
this._onAccepted(sipSession, response.session, false, false);
|
|
1264
1250
|
if (shouldDoScreenSharing) {
|
|
1265
1251
|
this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
|
|
@@ -1273,7 +1259,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1273
1259
|
},
|
|
1274
1260
|
sessionDescriptionHandlerOptions: {
|
|
1275
1261
|
constraints,
|
|
1276
|
-
// @ts-ignore
|
|
1277
1262
|
conference,
|
|
1278
1263
|
audioOnly,
|
|
1279
1264
|
offerOptions: {
|
|
@@ -1296,14 +1281,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1296
1281
|
if (!sipSession) {
|
|
1297
1282
|
return null;
|
|
1298
1283
|
}
|
|
1299
|
-
// @ts-ignore
|
|
1300
1284
|
return sipSession.sessionDescriptionHandler ? sipSession.sessionDescriptionHandler.peerConnection : null;
|
|
1301
1285
|
}
|
|
1302
1286
|
// Local streams
|
|
1303
1287
|
getLocalStream(sessionId) {
|
|
1304
1288
|
var _a;
|
|
1305
1289
|
const sipSession = this.sipSessions[sessionId];
|
|
1306
|
-
// @ts-ignore
|
|
1307
1290
|
return ((_a = sipSession === null || sipSession === void 0 ? void 0 : sipSession.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.localMediaStream) || null;
|
|
1308
1291
|
}
|
|
1309
1292
|
getLocalTracks(sessionId) {
|
|
@@ -1327,7 +1310,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1327
1310
|
getRemoteStream(sessionId) {
|
|
1328
1311
|
var _a;
|
|
1329
1312
|
const sipSession = this.sipSessions[sessionId];
|
|
1330
|
-
// @ts-ignore
|
|
1331
1313
|
return ((_a = sipSession === null || sipSession === void 0 ? void 0 : sipSession.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.remoteMediaStream) || null;
|
|
1332
1314
|
}
|
|
1333
1315
|
getRemoteTracks(sessionId) {
|
|
@@ -1365,19 +1347,17 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1365
1347
|
return this.hasALocalVideoTrack(sessionId) || this.hasARemoteVideoTrack(sessionId);
|
|
1366
1348
|
}
|
|
1367
1349
|
getSipSessionId(sipSession) {
|
|
1368
|
-
var _a;
|
|
1369
1350
|
if (!sipSession) {
|
|
1370
1351
|
return '';
|
|
1371
1352
|
}
|
|
1372
|
-
|
|
1373
|
-
if (
|
|
1374
|
-
|
|
1375
|
-
return sipSession.message.callId.substring(0, SIP_ID_LENGTH);
|
|
1353
|
+
const message = sipSession.message;
|
|
1354
|
+
if (message === null || message === void 0 ? void 0 : message.callId) {
|
|
1355
|
+
return message.callId.substring(0, SIP_ID_LENGTH);
|
|
1376
1356
|
}
|
|
1377
1357
|
// For Inviter
|
|
1378
|
-
// @ts-ignore
|
|
1358
|
+
// @ts-ignore: private
|
|
1379
1359
|
if (sipSession instanceof api_1.Inviter && sipSession.outgoingRequestMessage) {
|
|
1380
|
-
// @ts-ignore
|
|
1360
|
+
// @ts-ignore: private
|
|
1381
1361
|
return sipSession.outgoingRequestMessage.callId.substring(0, SIP_ID_LENGTH);
|
|
1382
1362
|
}
|
|
1383
1363
|
// For Invitation
|
|
@@ -1432,7 +1412,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1432
1412
|
if (!this.userAgent) {
|
|
1433
1413
|
return;
|
|
1434
1414
|
}
|
|
1435
|
-
// @ts-ignore
|
|
1415
|
+
// @ts-ignore: private
|
|
1436
1416
|
this.userAgent.attemptReconnection();
|
|
1437
1417
|
}
|
|
1438
1418
|
storeSipSession(session) {
|
|
@@ -1457,7 +1437,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1457
1437
|
});
|
|
1458
1438
|
if (sipSession.sessionDescriptionHandler) {
|
|
1459
1439
|
// eslint-disable-next-line no-underscore-dangle
|
|
1460
|
-
// @ts-ignore
|
|
1440
|
+
// @ts-ignore: protected
|
|
1461
1441
|
sipSession.sessionDescriptionHandler._localMediaStream = newStream;
|
|
1462
1442
|
}
|
|
1463
1443
|
}
|
|
@@ -1569,14 +1549,13 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1569
1549
|
return;
|
|
1570
1550
|
}
|
|
1571
1551
|
if ((_a = this.userAgent) === null || _a === void 0 ? void 0 : _a.transport) {
|
|
1572
|
-
// @ts-ignore
|
|
1573
1552
|
this.userAgent.transport.configuration.traceSip = true;
|
|
1574
1553
|
}
|
|
1575
|
-
// @ts-ignore
|
|
1554
|
+
// @ts-ignore: private
|
|
1576
1555
|
this.userAgent.loggerFactory.builtinEnabled = true;
|
|
1577
|
-
// @ts-ignore
|
|
1556
|
+
// @ts-ignore: private
|
|
1578
1557
|
this.userAgent.loggerFactory.level = 3; // debug
|
|
1579
|
-
// @ts-ignore
|
|
1558
|
+
// @ts-ignore: private
|
|
1580
1559
|
this.userAgent.loggerFactory.connector = logConnector;
|
|
1581
1560
|
}
|
|
1582
1561
|
_onHeartbeat(message) {
|
|
@@ -1604,8 +1583,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1604
1583
|
}
|
|
1605
1584
|
if (this.userAgent && this.userAgent.transport) {
|
|
1606
1585
|
// Disconnect from WS and triggers events, but do not trigger disconnect if already disconnecting...
|
|
1607
|
-
|
|
1608
|
-
|
|
1586
|
+
const transport = this.userAgent.transport;
|
|
1587
|
+
// @HEADS UP
|
|
1588
|
+
if (!transport.transitioningState && !transport.disconnectPromise) {
|
|
1609
1589
|
try {
|
|
1610
1590
|
yield this.userAgent.transport.disconnect();
|
|
1611
1591
|
}
|
|
@@ -1629,7 +1609,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1629
1609
|
}
|
|
1630
1610
|
_getAudioConstraints() {
|
|
1631
1611
|
var _a, _b;
|
|
1632
|
-
// @ts-ignore
|
|
1612
|
+
// @ts-ignore: media constraints
|
|
1633
1613
|
return ((_b = (_a = this.audio) === null || _a === void 0 ? void 0 : _a.deviceId) === null || _b === void 0 ? void 0 : _b.exact) ? this.audio : true;
|
|
1634
1614
|
}
|
|
1635
1615
|
_getVideoConstraints(video = false) {
|
|
@@ -1637,7 +1617,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1637
1617
|
if (!video) {
|
|
1638
1618
|
return false;
|
|
1639
1619
|
}
|
|
1640
|
-
// @ts-ignore
|
|
1620
|
+
// @ts-ignore: media constraints
|
|
1641
1621
|
return ((_b = (_a = this.video) === null || _a === void 0 ? void 0 : _a.deviceId) === null || _b === void 0 ? void 0 : _b.exact) ? this.video : true;
|
|
1642
1622
|
}
|
|
1643
1623
|
_connectIfNeeded() {
|
|
@@ -1652,7 +1632,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1652
1632
|
}
|
|
1653
1633
|
if (this.isConnecting()) {
|
|
1654
1634
|
logger.info('webrtc sdk, already connecting...');
|
|
1655
|
-
// @ts-ignore
|
|
1656
1635
|
this.connectionPromise = this.userAgent.transport.connectPromise;
|
|
1657
1636
|
return Promise.resolve(this.connectionPromise);
|
|
1658
1637
|
}
|
|
@@ -1663,11 +1642,10 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1663
1642
|
logger.info('WebRTC UA needs to connect');
|
|
1664
1643
|
// Force UA to reconnect
|
|
1665
1644
|
if (this.userAgent && this.userAgent.state !== user_agent_state_1.UserAgentState.Stopped) {
|
|
1666
|
-
// @ts-ignore
|
|
1645
|
+
// @ts-ignore: private
|
|
1667
1646
|
this.userAgent.transitionState(user_agent_state_1.UserAgentState.Stopped);
|
|
1668
1647
|
}
|
|
1669
1648
|
if (this.userAgent.transport && this.userAgent.transport.state !== transport_state_1.TransportState.Disconnected) {
|
|
1670
|
-
// @ts-ignore
|
|
1671
1649
|
this.userAgent.transport.transitionState(transport_state_1.TransportState.Disconnected);
|
|
1672
1650
|
}
|
|
1673
1651
|
this.connectionPromise = this.userAgent.start().catch(console.error);
|
|
@@ -1681,11 +1659,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1681
1659
|
const client = new api_client_1.default({
|
|
1682
1660
|
server: `${config.host}:${String(config.port || 443)}`,
|
|
1683
1661
|
});
|
|
1684
|
-
// @ts-ignore
|
|
1685
1662
|
client.setToken(session.token);
|
|
1686
|
-
// @ts-ignore
|
|
1687
1663
|
client.setRefreshToken(session.refreshToken);
|
|
1688
|
-
// @ts-ignore
|
|
1689
1664
|
return client.confd.getUserLineSipFromToken(session.uuid).then(sipLine => (Object.assign({ authorizationUser: sipLine.username, password: sipLine.secret, uri: `${sipLine.username}@${config.host}` }, config)));
|
|
1690
1665
|
}
|
|
1691
1666
|
_createUaOptions(uaOptionsOverrides = {}) {
|
|
@@ -1716,7 +1691,6 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1716
1691
|
sessionDescriptionHandlerFactory: (session, options = {}) => {
|
|
1717
1692
|
const uaLogger = session.userAgent.getLogger('sip.WazoSessionDescriptionHandler');
|
|
1718
1693
|
const isWeb = this._isWeb();
|
|
1719
|
-
// @ts-ignore
|
|
1720
1694
|
const iceGatheringTimeout = 'peerConnectionOptions' in options ? options.peerConnectionOptions.iceGatheringTimeout || DEFAULT_ICE_TIMEOUT : DEFAULT_ICE_TIMEOUT;
|
|
1721
1695
|
const sdhOptions = Object.assign(Object.assign({}, options), { iceGatheringTimeout, peerConnectionConfiguration: Object.assign(Object.assign({}, (0, peer_connection_configuration_default_1.defaultPeerConnectionConfiguration)()), (options.peerConnectionConfiguration || {})) });
|
|
1722
1696
|
return new WazoSessionDescriptionHandler_1.default(uaLogger, WazoSessionDescriptionHandler_1.wazoMediaStreamFactory, sdhOptions, isWeb, session);
|
|
@@ -1761,8 +1735,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1761
1735
|
session.delegate = {};
|
|
1762
1736
|
}
|
|
1763
1737
|
session.delegate.onSessionDescriptionHandler = (sdh) => {
|
|
1764
|
-
|
|
1765
|
-
sdh.on('error', e => {
|
|
1738
|
+
sdh.on('error', (e) => {
|
|
1766
1739
|
this.eventEmitter.emit(ON_ERROR, e);
|
|
1767
1740
|
});
|
|
1768
1741
|
sdh.peerConnectionDelegate = {
|
|
@@ -1777,12 +1750,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1777
1750
|
},
|
|
1778
1751
|
};
|
|
1779
1752
|
};
|
|
1780
|
-
// @ts-ignore
|
|
1753
|
+
// @ts-ignore: protected
|
|
1781
1754
|
const oldInviteRequest = session.onInviteRequest.bind(session);
|
|
1782
1755
|
let hadRemoteVideo = false;
|
|
1783
1756
|
// Monkey patch `onInviteRequest` to be able to know if there was a remote video stream before `onInvite` is called
|
|
1784
1757
|
// Because when `onInvite` is called we already got the video track
|
|
1785
|
-
// @ts-ignore
|
|
1758
|
+
// @ts-ignore: protected
|
|
1786
1759
|
session.onInviteRequest = request => {
|
|
1787
1760
|
hadRemoteVideo = this.hasARemoteVideoTrack(sipSessionId);
|
|
1788
1761
|
oldInviteRequest(request);
|
|
@@ -1791,7 +1764,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1791
1764
|
let updatedCalleeName = null;
|
|
1792
1765
|
let updatedNumber = null;
|
|
1793
1766
|
if (session.assertedIdentity) {
|
|
1794
|
-
// @ts-ignore
|
|
1767
|
+
// @ts-ignore: private
|
|
1795
1768
|
updatedNumber = session.assertedIdentity.uri.normal.user;
|
|
1796
1769
|
updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
|
|
1797
1770
|
}
|
|
@@ -1804,12 +1777,12 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1804
1777
|
// Update SDP
|
|
1805
1778
|
// Remote video is handled by the `track` event. Here we're dealing with video stream removal.
|
|
1806
1779
|
if (session instanceof api_1.Invitation) {
|
|
1807
|
-
// @ts-ignore
|
|
1780
|
+
// @ts-ignore: private
|
|
1808
1781
|
session.incomingInviteRequest.message.body = request.body;
|
|
1809
|
-
// @ts-ignore
|
|
1782
|
+
// @ts-ignore: private
|
|
1810
1783
|
}
|
|
1811
1784
|
else if (session instanceof api_1.Inviter && session.outgoingInviteRequest.message.body) {
|
|
1812
|
-
// @ts-ignore
|
|
1785
|
+
// @ts-ignore: private
|
|
1813
1786
|
session.outgoingInviteRequest.message.body.body = request.body;
|
|
1814
1787
|
}
|
|
1815
1788
|
this.updateRemoteStream(sipSessionId, false);
|
|
@@ -1831,13 +1804,11 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1831
1804
|
logger.info('on call accepted', {
|
|
1832
1805
|
id: session.id,
|
|
1833
1806
|
clientId: this.clientId,
|
|
1834
|
-
// @ts-ignore
|
|
1835
1807
|
remoteTag: session.remoteTag,
|
|
1836
1808
|
});
|
|
1837
1809
|
this.storeSipSession(session);
|
|
1838
1810
|
this._setupMedias(session);
|
|
1839
1811
|
this.updateRemoteStream(this.getSipSessionId(session), initAllTracks);
|
|
1840
|
-
// @ts-ignore
|
|
1841
1812
|
const pc = (_a = session.sessionDescriptionHandler) === null || _a === void 0 ? void 0 : _a.peerConnection;
|
|
1842
1813
|
const onTrack = (event) => {
|
|
1843
1814
|
const isAudioOnly = this._isAudioOnly(session);
|
|
@@ -1856,13 +1827,11 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1856
1827
|
}
|
|
1857
1828
|
this.eventEmitter.emit(ON_TRACK, session, event);
|
|
1858
1829
|
};
|
|
1859
|
-
|
|
1860
|
-
if (
|
|
1861
|
-
|
|
1862
|
-
session.sessionDescriptionHandler.peerConnection.addEventListener('track', onTrack);
|
|
1830
|
+
const sessionDescriptionHandler = session.sessionDescriptionHandler;
|
|
1831
|
+
if (sessionDescriptionHandler === null || sessionDescriptionHandler === void 0 ? void 0 : sessionDescriptionHandler.peerConnection) {
|
|
1832
|
+
sessionDescriptionHandler.peerConnection.addEventListener('track', onTrack);
|
|
1863
1833
|
}
|
|
1864
|
-
|
|
1865
|
-
session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
1834
|
+
sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
|
|
1866
1835
|
if (pc) {
|
|
1867
1836
|
pc.oniceconnectionstatechange = () => {
|
|
1868
1837
|
logger.info('on ice connection state changed', {
|
|
@@ -1899,11 +1868,10 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1899
1868
|
this.createAudioElementFor(sessionId);
|
|
1900
1869
|
}
|
|
1901
1870
|
const audioElement = this.audioElements[sessionId];
|
|
1902
|
-
// @ts-ignore
|
|
1903
1871
|
const sipSession = this.sipSessions[session.callId];
|
|
1904
1872
|
const removeStream = this.getRemoteStream(sessionId);
|
|
1905
|
-
|
|
1906
|
-
const earlyStream =
|
|
1873
|
+
const sdh = sipSession.sessionDescriptionHandler;
|
|
1874
|
+
const earlyStream = sdh ? sdh.remoteMediaStream : null;
|
|
1907
1875
|
const stream = newStream || removeStream || earlyStream;
|
|
1908
1876
|
if (!stream) {
|
|
1909
1877
|
logger.info('Setup media no stream to attach, bailing');
|
|
@@ -1963,8 +1931,8 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1963
1931
|
stream.getTracks().filter(track => track.enabled).forEach(track => track.stop());
|
|
1964
1932
|
}
|
|
1965
1933
|
_toggleAudio(session, muteAudio) {
|
|
1966
|
-
|
|
1967
|
-
const pc =
|
|
1934
|
+
const sdh = session.sessionDescriptionHandler;
|
|
1935
|
+
const pc = ((sdh === null || sdh === void 0 ? void 0 : sdh.peerConnection) || null);
|
|
1968
1936
|
if (!pc) {
|
|
1969
1937
|
return;
|
|
1970
1938
|
}
|
|
@@ -1986,10 +1954,9 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
1986
1954
|
}
|
|
1987
1955
|
}
|
|
1988
1956
|
_toggleVideo(session, muteCamera) {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
if (pc.getSenders) {
|
|
1957
|
+
const sdh = session.sessionDescriptionHandler;
|
|
1958
|
+
const pc = sdh === null || sdh === void 0 ? void 0 : sdh.peerConnection;
|
|
1959
|
+
if (pc === null || pc === void 0 ? void 0 : pc.getSenders) {
|
|
1993
1960
|
pc.getSenders().forEach((sender) => {
|
|
1994
1961
|
if (sender && sender.track && sender.track.kind === 'video') {
|
|
1995
1962
|
// eslint-disable-next-line
|
|
@@ -2027,14 +1994,14 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2027
1994
|
}
|
|
2028
1995
|
_cleanupRegister() {
|
|
2029
1996
|
if (this.registerer) {
|
|
2030
|
-
// @ts-ignore
|
|
1997
|
+
// @ts-ignore: removeAllListeners does not exist
|
|
2031
1998
|
this.registerer.stateChange.removeAllListeners();
|
|
2032
1999
|
this.registerer = null;
|
|
2033
2000
|
}
|
|
2034
2001
|
}
|
|
2035
2002
|
_startSendingStats(session) {
|
|
2036
|
-
|
|
2037
|
-
const pc =
|
|
2003
|
+
const sdh = session.sessionDescriptionHandler;
|
|
2004
|
+
const pc = sdh.peerConnection;
|
|
2038
2005
|
if (!pc) {
|
|
2039
2006
|
return;
|
|
2040
2007
|
}
|
|
@@ -2063,23 +2030,21 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2063
2030
|
return user_agent_1.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
|
|
2064
2031
|
}
|
|
2065
2032
|
_disconnectTransport(force = false) {
|
|
2033
|
+
var _a;
|
|
2066
2034
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2067
|
-
|
|
2035
|
+
const transport = (_a = this.userAgent) === null || _a === void 0 ? void 0 : _a.transport;
|
|
2036
|
+
if (force && transport) {
|
|
2068
2037
|
// Bypass sip.js state machine that prevent to close WS with the state `Connecting`
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
if (this.userAgent.transport._ws) {
|
|
2073
|
-
// @ts-ignore
|
|
2074
|
-
this.userAgent.transport._ws.close(1000);
|
|
2038
|
+
transport.disconnectResolve = () => { };
|
|
2039
|
+
if (transport._ws) {
|
|
2040
|
+
transport._ws.close(1000);
|
|
2075
2041
|
}
|
|
2076
2042
|
return;
|
|
2077
2043
|
}
|
|
2078
2044
|
// Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
|
|
2079
|
-
|
|
2080
|
-
if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
|
|
2045
|
+
if (transport && !transport.disconnectPromise) {
|
|
2081
2046
|
try {
|
|
2082
|
-
yield
|
|
2047
|
+
yield transport.disconnect();
|
|
2083
2048
|
}
|
|
2084
2049
|
catch (e) {
|
|
2085
2050
|
logger.error('WebRTC transport disconnect, error', e);
|
|
@@ -2197,7 +2162,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2197
2162
|
logger.warn(error, { state: session.state, sessionId: session.id });
|
|
2198
2163
|
throw new Error(error);
|
|
2199
2164
|
}
|
|
2200
|
-
// @ts-ignore
|
|
2165
|
+
// @ts-ignore: private
|
|
2201
2166
|
if (!session.incomingInviteRequest.acceptable) {
|
|
2202
2167
|
const error = 'Trying to reject a non `acceptable` session';
|
|
2203
2168
|
logger.warn(error, { state: session.state, sessionId: session.id });
|
|
@@ -2217,7 +2182,7 @@ class WebRTCClient extends Emitter_1.default {
|
|
|
2217
2182
|
logger.warn('Trying to reject a session in a wrong state', { state: session.state, sessionId: session.id });
|
|
2218
2183
|
return;
|
|
2219
2184
|
}
|
|
2220
|
-
// @ts-ignore
|
|
2185
|
+
// @ts-ignore: private
|
|
2221
2186
|
if (!session.incomingInviteRequest.rejectable) {
|
|
2222
2187
|
logger.warn('Trying to reject a non `rejectable` session', { state: session.state, sessionId: session.id });
|
|
2223
2188
|
return;
|