@wazo/sdk 1.0.0-alpha.0 → 1.0.0-alpha.10
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 +16 -7
- package/dist/wazo-sdk.js +6 -6
- package/esm/__tests__/__voice__/call.test.js +57 -2
- package/esm/__tests__/api-client.test.js +20 -1
- package/esm/api/auth.js +16 -2
- package/esm/checker/checks/webrtc.js +2 -2
- package/esm/domain/CallLog.js +2 -3
- package/esm/domain/Phone/CTIPhone.js +2 -2
- package/esm/domain/Phone/WebRTCPhone.js +64 -63
- package/esm/index.js +5 -1
- package/esm/service/CallApi.js +4 -4
- package/esm/simple/Auth.js +19 -15
- package/esm/simple/Phone.js +6 -5
- package/esm/simple/__tests__/Auth.test.js +8 -64
- package/esm/simple/index.js +2 -1
- package/esm/simple/room/Room.js +2 -2
- package/esm/simple/room/SipRoom.js +2 -2
- package/esm/state-machine/call-state-machine.js +2 -2
- package/esm/state-machine/softphone-state-machine.js +1 -2
- package/esm/state-machine/utils.js +8 -3
- package/esm/types/api/auth.d.ts +3 -0
- package/esm/types/api/auth.d.ts.map +1 -1
- package/esm/types/checker/checks/index.d.ts +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/CallLog.d.ts.map +1 -1
- package/esm/types/domain/CallSession.d.ts +3 -3
- package/esm/types/domain/CallSession.d.ts.map +1 -1
- package/esm/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/esm/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/esm/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/esm/types/domain/types.d.ts +0 -4
- package/esm/types/domain/types.d.ts.map +1 -1
- package/esm/types/index.d.ts +5 -1
- package/esm/types/index.d.ts.map +1 -1
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/esm/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/esm/types/service/CallApi.d.ts +5 -5
- package/esm/types/service/CallApi.d.ts.map +1 -1
- package/esm/types/simple/Auth.d.ts +6 -1
- package/esm/types/simple/Auth.d.ts.map +1 -1
- package/esm/types/simple/Phone.d.ts +8 -8
- package/esm/types/simple/Phone.d.ts.map +1 -1
- package/esm/types/simple/index.d.ts +3 -1
- package/esm/types/simple/index.d.ts.map +1 -1
- package/esm/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/esm/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/esm/types/state-machine/utils.d.ts +2 -2
- package/esm/types/state-machine/utils.d.ts.map +1 -1
- package/esm/types/utils/api-requester.d.ts.map +1 -1
- package/esm/types/utils/sdp.d.ts +3 -2
- package/esm/types/utils/sdp.d.ts.map +1 -1
- package/esm/types/utils/webrtc.d.ts +1 -0
- package/esm/types/utils/webrtc.d.ts.map +1 -1
- package/esm/types/voice/call.d.ts +30 -12
- package/esm/types/voice/call.d.ts.map +1 -1
- package/esm/types/voice/softphone.d.ts +25 -13
- package/esm/types/voice/softphone.d.ts.map +1 -1
- package/esm/types/web-rtc-client.d.ts +39 -38
- package/esm/types/web-rtc-client.d.ts.map +1 -1
- package/esm/utils/__tests__/api-requester.test.js +17 -0
- package/esm/utils/api-requester.js +9 -1
- package/esm/utils/sdp.js +22 -9
- package/esm/utils/webrtc.js +24 -4
- package/esm/voice/call.js +130 -38
- package/esm/voice/softphone.js +145 -35
- package/esm/web-rtc-client.js +61 -58
- package/lib/__tests__/__voice__/call.test.js +56 -1
- package/lib/__tests__/api-client.test.js +20 -1
- package/lib/api/auth.js +16 -2
- package/lib/checker/checks/webrtc.js +1 -1
- package/lib/domain/CallLog.js +2 -3
- package/lib/domain/Phone/CTIPhone.js +2 -2
- package/lib/domain/Phone/WebRTCPhone.js +63 -62
- package/lib/index.js +11 -3
- package/lib/service/CallApi.js +2 -2
- package/lib/simple/Auth.js +21 -15
- package/lib/simple/Phone.js +3 -2
- package/lib/simple/__tests__/Auth.test.js +11 -64
- package/lib/simple/index.js +2 -1
- package/lib/simple/room/Room.js +1 -1
- package/lib/simple/room/SipRoom.js +1 -1
- package/lib/state-machine/call-state-machine.js +2 -2
- package/lib/state-machine/softphone-state-machine.js +1 -2
- package/lib/state-machine/utils.js +8 -3
- package/lib/types/api/auth.d.ts +3 -0
- package/lib/types/api/auth.d.ts.map +1 -1
- package/lib/types/checker/checks/index.d.ts +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/CallLog.d.ts.map +1 -1
- package/lib/types/domain/CallSession.d.ts +3 -3
- package/lib/types/domain/CallSession.d.ts.map +1 -1
- package/lib/types/domain/Phone/CTIPhone.d.ts.map +1 -1
- package/lib/types/domain/Phone/WebRTCPhone.d.ts +22 -22
- package/lib/types/domain/Phone/WebRTCPhone.d.ts.map +1 -1
- package/lib/types/domain/types.d.ts +0 -4
- package/lib/types/domain/types.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts +3 -3
- package/lib/types/lib/WazoSessionDescriptionHandler.d.ts.map +1 -1
- package/lib/types/service/CallApi.d.ts +5 -5
- package/lib/types/service/CallApi.d.ts.map +1 -1
- package/lib/types/simple/Auth.d.ts +6 -1
- package/lib/types/simple/Auth.d.ts.map +1 -1
- package/lib/types/simple/Phone.d.ts +8 -8
- package/lib/types/simple/Phone.d.ts.map +1 -1
- package/lib/types/simple/index.d.ts +3 -1
- package/lib/types/simple/index.d.ts.map +1 -1
- package/lib/types/state-machine/softphone-state-machine.d.ts +1 -2
- package/lib/types/state-machine/softphone-state-machine.d.ts.map +1 -1
- package/lib/types/state-machine/utils.d.ts +2 -2
- package/lib/types/state-machine/utils.d.ts.map +1 -1
- package/lib/types/utils/api-requester.d.ts.map +1 -1
- package/lib/types/utils/sdp.d.ts +3 -2
- package/lib/types/utils/sdp.d.ts.map +1 -1
- package/lib/types/utils/webrtc.d.ts +1 -0
- package/lib/types/utils/webrtc.d.ts.map +1 -1
- package/lib/types/voice/call.d.ts +30 -12
- package/lib/types/voice/call.d.ts.map +1 -1
- package/lib/types/voice/softphone.d.ts +25 -13
- package/lib/types/voice/softphone.d.ts.map +1 -1
- package/lib/types/web-rtc-client.d.ts +39 -38
- package/lib/types/web-rtc-client.d.ts.map +1 -1
- package/lib/utils/__tests__/api-requester.test.js +17 -0
- package/lib/utils/api-requester.js +9 -1
- package/lib/utils/sdp.js +25 -10
- package/lib/utils/webrtc.js +25 -4
- package/lib/voice/call.js +131 -36
- package/lib/voice/softphone.js +150 -35
- package/lib/web-rtc-client.js +59 -57
- package/package.json +1 -1
- package/src/__tests__/__voice__/call.test.ts +63 -2
- package/src/__tests__/api-client.test.ts +22 -1
- package/src/api/auth.ts +30 -3
- package/src/checker/checks/webrtc-transport.ts +2 -2
- package/src/checker/checks/webrtc.ts +2 -2
- package/src/domain/CallLog.ts +2 -3
- package/src/domain/CallSession.ts +3 -3
- package/src/domain/Phone/CTIPhone.ts +3 -2
- package/src/domain/Phone/WebRTCPhone.ts +95 -93
- package/src/domain/types.ts +0 -5
- package/src/index.ts +6 -1
- package/src/lib/WazoSessionDescriptionHandler.ts +3 -3
- package/src/service/CallApi.ts +7 -7
- package/src/simple/Auth.ts +21 -16
- package/src/simple/Phone.ts +12 -11
- package/src/simple/__tests__/Auth.test.ts +9 -87
- package/src/simple/index.ts +2 -1
- package/src/simple/room/Room.ts +3 -3
- package/src/simple/room/SipRoom.ts +3 -3
- package/src/state-machine/call-state-machine.ts +2 -2
- package/src/state-machine/softphone-state-machine.ts +1 -2
- package/src/state-machine/utils.ts +12 -5
- package/src/utils/__tests__/api-requester.test.ts +20 -0
- package/src/utils/api-requester.ts +9 -1
- package/src/utils/sdp.ts +26 -11
- package/src/utils/webrtc.ts +27 -5
- package/src/voice/call.ts +169 -50
- package/src/voice/softphone.ts +180 -41
- package/src/web-rtc-client.ts +106 -99
package/lib/domain/CallLog.js
CHANGED
|
@@ -46,8 +46,7 @@ class CallLog {
|
|
|
46
46
|
}
|
|
47
47
|
static parseNew(plain, session) {
|
|
48
48
|
const callLog = CallLog.parse(plain);
|
|
49
|
-
|
|
50
|
-
callLog.newMissedCall = session && session.hasExtension((plain.requested_extension || plain.destination_extension)) && !plain.answered;
|
|
49
|
+
callLog.newMissedCall = session && plain.destination_user_uuid === session.uuid && !plain.answered;
|
|
51
50
|
return callLog;
|
|
52
51
|
}
|
|
53
52
|
static newFrom(profile) {
|
|
@@ -105,7 +104,7 @@ class CallLog {
|
|
|
105
104
|
return this.callDirection === 'inbound';
|
|
106
105
|
}
|
|
107
106
|
isAnOutgoingCall(session) {
|
|
108
|
-
console.warn(`@wazo/sdk
|
|
107
|
+
console.warn(`@wazo/sdk
|
|
109
108
|
CallLog.isAnOutgoingcall(session) method is obsolete.
|
|
110
109
|
Please use CallLog.isOutgoing(session).
|
|
111
110
|
`);
|
|
@@ -119,7 +119,7 @@ class CTIPhone extends Emitter_1.default {
|
|
|
119
119
|
number: callSession.number,
|
|
120
120
|
});
|
|
121
121
|
try {
|
|
122
|
-
yield CallApi_1.default.cancelCall(callSession);
|
|
122
|
+
yield CallApi_1.default.cancelCall({ apiId: callSession.getId() });
|
|
123
123
|
if (this.currentCall && callSession.callId === this.currentCall.id) {
|
|
124
124
|
this.endCurrentCall(callSession);
|
|
125
125
|
}
|
|
@@ -143,7 +143,7 @@ class CTIPhone extends Emitter_1.default {
|
|
|
143
143
|
callId: callSession.getId(),
|
|
144
144
|
number: callSession.number,
|
|
145
145
|
});
|
|
146
|
-
yield CallApi_1.default.cancelCall(callSession);
|
|
146
|
+
yield CallApi_1.default.cancelCall({ id: callSession.getId() });
|
|
147
147
|
this.eventEmitter.emit('onCallEnded', callSession);
|
|
148
148
|
});
|
|
149
149
|
}
|
|
@@ -66,6 +66,7 @@ exports.MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
|
|
|
66
66
|
exports.MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
|
|
67
67
|
exports.events = [exports.ON_USER_AGENT, exports.ON_REGISTERED, exports.ON_UNREGISTERED, exports.ON_PROGRESS, exports.ON_CALL_ACCEPTED, exports.ON_CALL_ANSWERED, exports.ON_CALL_INCOMING, exports.ON_CALL_OUTGOING, exports.ON_CALL_MUTED, exports.ON_CALL_UNMUTED, exports.ON_CALL_RESUMED, exports.ON_CALL_HELD, exports.ON_CALL_UNHELD, exports.ON_CAMERA_DISABLED, exports.ON_CALL_FAILED, exports.ON_CALL_ENDED, exports.ON_CALL_REJECTED, exports.ON_MESSAGE, exports.ON_REINVITE, exports.ON_TRACK, exports.ON_AUDIO_STREAM, exports.ON_VIDEO_STREAM, exports.ON_REMOVE_STREAM, exports.ON_SHARE_SCREEN_ENDED, exports.ON_TERMINATE_SOUND, exports.ON_PLAY_RING_SOUND, exports.ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, exports.ON_PLAY_HANGUP_SOUND, exports.ON_PLAY_PROGRESS_SOUND, exports.ON_VIDEO_INPUT_CHANGE, exports.ON_SHARE_SCREEN_STARTED, exports.ON_CALL_ERROR, exports.ON_CHAT, exports.ON_SIGNAL, exports.ON_NETWORK_STATS, exports.ON_DISCONNECTED, exports.ON_EARLY_MEDIA];
|
|
68
68
|
const logger = IssueReporter_1.default.loggerFor('webrtc-phone');
|
|
69
|
+
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
69
70
|
class WebRTCPhone extends Emitter_1.default {
|
|
70
71
|
constructor(client, audioOutputDeviceId, allowVideo = false, audioRingDeviceId) {
|
|
71
72
|
super();
|
|
@@ -124,7 +125,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
124
125
|
return __awaiter(this, arguments, void 0, function* (callSession, constraints = null, conference = false, audioOnly = false, iceRestart = false) {
|
|
125
126
|
const sipSession = this.findSipSession(callSession);
|
|
126
127
|
logger.info('WebRTC phone - send reinvite', {
|
|
127
|
-
sessionId:
|
|
128
|
+
sessionId: (0, sdp_1.getSipCallId)(sipSession),
|
|
128
129
|
constraints,
|
|
129
130
|
audioOnly,
|
|
130
131
|
conference,
|
|
@@ -282,7 +283,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
282
283
|
content: {
|
|
283
284
|
type: exports.ON_MESSAGE_TRACK_UPDATED,
|
|
284
285
|
update: isUpgrade ? 'upgrade' : 'downgrade',
|
|
285
|
-
sipCallId: sipSession && (0, sdp_1.
|
|
286
|
+
sipCallId: sipSession && (0, sdp_1.getSipCallId)(sipSession),
|
|
286
287
|
callId: callSession ? callSession.callId : null,
|
|
287
288
|
number: callSession ? callSession.number : null,
|
|
288
289
|
},
|
|
@@ -290,7 +291,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
290
291
|
}, 2500);
|
|
291
292
|
}
|
|
292
293
|
_bindEvents(sipSession) {
|
|
293
|
-
const sipSessionId = (0, sdp_1.
|
|
294
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
294
295
|
if (sipSession instanceof api_1.Invitation) {
|
|
295
296
|
// Monkey patch to know when canceled with the CANCEL message
|
|
296
297
|
const onCancel = sipSession._onCancel.bind(sipSession);
|
|
@@ -302,7 +303,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
302
303
|
onCancel(message);
|
|
303
304
|
const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
|
|
304
305
|
const callSession = this._createCallSession(sipSession);
|
|
305
|
-
|
|
306
|
+
if (sipSessionId) {
|
|
307
|
+
delete this.callSessions[sipSessionId];
|
|
308
|
+
}
|
|
306
309
|
this.eventEmitter.emit(exports.ON_CALL_CANCELED, callSession, elsewhere);
|
|
307
310
|
};
|
|
308
311
|
}
|
|
@@ -310,14 +313,14 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
310
313
|
switch (newState) {
|
|
311
314
|
case session_state_1.SessionState.Terminating:
|
|
312
315
|
logger.info('WebRTC phone - call terminating', {
|
|
313
|
-
sipId: sipSession
|
|
316
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
314
317
|
});
|
|
315
318
|
this.eventEmitter.emit(exports.ON_CALL_ENDING, this._createCallSession(sipSession));
|
|
316
319
|
break;
|
|
317
320
|
case session_state_1.SessionState.Terminated:
|
|
318
321
|
{
|
|
319
322
|
logger.info('WebRTC phone - call terminated', {
|
|
320
|
-
sipId: sipSession
|
|
323
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
321
324
|
});
|
|
322
325
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
323
326
|
const callSession = this._createCallSession(sipSession);
|
|
@@ -344,7 +347,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
344
347
|
const [stream] = event.streams;
|
|
345
348
|
const kind = event && event.track && event.track.kind;
|
|
346
349
|
logger.info('on track stream called on the peer connection', {
|
|
347
|
-
callId: (0, sdp_1.
|
|
350
|
+
callId: (0, sdp_1.getSipCallId)(sipSession),
|
|
348
351
|
streamId: stream ? stream.id : null,
|
|
349
352
|
tracks: stream ? stream.getTracks() : null,
|
|
350
353
|
kind,
|
|
@@ -374,9 +377,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
374
377
|
}
|
|
375
378
|
const screenTrack = screenShareStream.getVideoTracks()[0];
|
|
376
379
|
const sipSession = this.currentSipSession;
|
|
377
|
-
const pc = sipSession && this.client.getPeerConnection((0, sdp_1.
|
|
380
|
+
const pc = sipSession && this.client.getPeerConnection((0, sdp_1.getSipCallId)(sipSession));
|
|
378
381
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
379
|
-
const localStream = sipSession && this.client.getLocalStream((0, sdp_1.
|
|
382
|
+
const localStream = sipSession && this.client.getLocalStream((0, sdp_1.getSipCallId)(sipSession));
|
|
380
383
|
const videoTrack = localStream ? localStream.getTracks().find(track => track.kind === 'video') : null;
|
|
381
384
|
const hadVideo = !!videoTrack;
|
|
382
385
|
// Stop local video tracks
|
|
@@ -441,19 +444,19 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
441
444
|
}
|
|
442
445
|
_onScreenSharing(screenStream, sipSession, callSession, hadVideo, desktop) {
|
|
443
446
|
const screenTrack = screenStream.getVideoTracks()[0];
|
|
444
|
-
const sipSessionId = (0, sdp_1.
|
|
447
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
445
448
|
const pc = this.client.getPeerConnection(sipSessionId);
|
|
446
449
|
const sender = pc && pc.getSenders && pc.getSenders().find((s) => s && s.track && s.track.kind === 'video');
|
|
447
450
|
logger.info('WebRTC phone - on screensharing', {
|
|
448
451
|
hadVideo,
|
|
449
|
-
id: (0, sdp_1.
|
|
452
|
+
id: (0, sdp_1.getSipCallId)(sipSession),
|
|
450
453
|
screenTrack,
|
|
451
454
|
});
|
|
452
455
|
if (screenTrack) {
|
|
453
456
|
screenTrack.onended = () => {
|
|
454
457
|
logger.info('WebRTC phone - on screenshare ended', {
|
|
455
458
|
hadVideo,
|
|
456
|
-
id: (0, sdp_1.
|
|
459
|
+
id: (0, sdp_1.getSipCallId)(sipSession),
|
|
457
460
|
screenTrack,
|
|
458
461
|
});
|
|
459
462
|
this.eventEmitter.emit(exports.ON_SHARE_SCREEN_ENDING, this._createCallSession(sipSession, callSession));
|
|
@@ -473,13 +476,13 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
473
476
|
}
|
|
474
477
|
_onCallAccepted(sipSession, cameraEnabled) {
|
|
475
478
|
logger.info('WebRTC phone - on call accepted', {
|
|
476
|
-
sipId: sipSession
|
|
479
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
477
480
|
cameraEnabled,
|
|
478
481
|
});
|
|
479
482
|
const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
|
|
480
483
|
if (this.currentSipSession && !this.isCurrentCallSipSession(callSession)) {
|
|
481
484
|
logger.info('WebRTC phone - on call accepted with another ongoing call, holding it', {
|
|
482
|
-
sipId: sipSession
|
|
485
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
483
486
|
cameraEnabled,
|
|
484
487
|
});
|
|
485
488
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
|
|
@@ -487,7 +490,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
487
490
|
this.currentSipSession = sipSession;
|
|
488
491
|
this.currentCallSession = callSession;
|
|
489
492
|
this.eventEmitter.emit(exports.ON_TERMINATE_SOUND, callSession, 'call accepted');
|
|
490
|
-
const sipSessionId = (0, sdp_1.
|
|
493
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
491
494
|
if (sipSessionId) {
|
|
492
495
|
this.removeIncomingSessions(sipSessionId);
|
|
493
496
|
}
|
|
@@ -550,9 +553,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
550
553
|
return this.currentSipSession && this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
|
|
551
554
|
}
|
|
552
555
|
_onCallTerminated(sipSession) {
|
|
553
|
-
const sipSessionId = (0, sdp_1.
|
|
556
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
554
557
|
logger.info('WebRTC phone - on call terminated', {
|
|
555
|
-
sipId: sipSession
|
|
558
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
556
559
|
sipSessionId,
|
|
557
560
|
ids: Object.keys(this.callSessions),
|
|
558
561
|
});
|
|
@@ -572,8 +575,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
572
575
|
}
|
|
573
576
|
if (sipSessionId) {
|
|
574
577
|
this.removeIncomingSessions(sipSessionId);
|
|
578
|
+
delete this.callSessions[sipSessionId];
|
|
575
579
|
}
|
|
576
|
-
delete this.callSessions[sipSessionId];
|
|
577
580
|
if (isCurrentSession) {
|
|
578
581
|
this.currentSipSession = undefined;
|
|
579
582
|
this.currentCallSession = undefined;
|
|
@@ -581,7 +584,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
581
584
|
const hasIncomingCallSession = this.hasIncomingCallSession();
|
|
582
585
|
// Re-trigger incoming call event for remaining incoming calls
|
|
583
586
|
logger.info('WebRTC phone - check to re-trigger incoming call', {
|
|
584
|
-
sipId: sipSession
|
|
587
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
585
588
|
shouldRetrigger,
|
|
586
589
|
hasIncomingCallSession,
|
|
587
590
|
});
|
|
@@ -642,7 +645,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
642
645
|
if (!this.currentSipSession) {
|
|
643
646
|
return false;
|
|
644
647
|
}
|
|
645
|
-
return this.currentSipSession && (0, sdp_1.
|
|
648
|
+
return this.currentSipSession && (0, sdp_1.getSipCallId)(this.currentSipSession) === callSession.getId();
|
|
646
649
|
}
|
|
647
650
|
hasVideo(callSession) {
|
|
648
651
|
return this.client.hasVideo(callSession.getId());
|
|
@@ -676,7 +679,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
676
679
|
logger.warn('no CallSession to accept.');
|
|
677
680
|
return Promise.resolve(null);
|
|
678
681
|
}
|
|
679
|
-
const sipSessionId = this.
|
|
682
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
680
683
|
if (sipSessionId && !(sipSessionId in this.callSessions)) {
|
|
681
684
|
logger.warn('Call session already ended or not found, can\'t accept it.', {
|
|
682
685
|
sipSessionId,
|
|
@@ -696,7 +699,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
696
699
|
this.eventEmitter.emit(exports.ON_CALL_ANSWERED, callSession);
|
|
697
700
|
const sipSession = this.client.getSipSession(callSession.getId());
|
|
698
701
|
if (sipSession) {
|
|
699
|
-
logger.info('accept call, session found', { sipId: sipSession
|
|
702
|
+
logger.info('accept call, session found', { sipId: (0, sdp_1.getSipCallId)(sipSession) });
|
|
700
703
|
return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
|
|
701
704
|
return callSession.sipCallId;
|
|
702
705
|
}).catch(e => {
|
|
@@ -708,7 +711,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
708
711
|
const error = 'No CallSession found to accept.';
|
|
709
712
|
logger.warn(error, {
|
|
710
713
|
id: callSession ? callSession.getId() : 'n/a',
|
|
711
|
-
ids: this.client.
|
|
714
|
+
ids: this.client.getSipCallIds(),
|
|
712
715
|
});
|
|
713
716
|
if (callSession) {
|
|
714
717
|
this.eventEmitter.emit(exports.ON_CALL_ERROR, new Error(error), callSession);
|
|
@@ -732,7 +735,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
732
735
|
const sipSession = this.findSipSession(callSession);
|
|
733
736
|
if (sipSession) {
|
|
734
737
|
logger.info('WebRTC rejecting', {
|
|
735
|
-
sipId: sipSession
|
|
738
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
736
739
|
});
|
|
737
740
|
this.client.hangup(sipSession);
|
|
738
741
|
}
|
|
@@ -753,7 +756,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
753
756
|
const sipSession = this.findSipSession(callSession);
|
|
754
757
|
if (sipSession) {
|
|
755
758
|
logger.info('WebRTC atxfer', {
|
|
756
|
-
sipId: sipSession
|
|
759
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
757
760
|
});
|
|
758
761
|
return this.client.atxfer(sipSession);
|
|
759
762
|
}
|
|
@@ -779,12 +782,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
779
782
|
return new Promise((resolve, reject) => reject(new Error('No session to resume')));
|
|
780
783
|
}
|
|
781
784
|
logger.info('WebRTC resuming', {
|
|
782
|
-
sipId: sipSession
|
|
785
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
783
786
|
});
|
|
784
787
|
// Hold current session if different from the current one (we don't want 2 sessions active at the same time).
|
|
785
|
-
if (this.currentSipSession && this.currentSipSession
|
|
788
|
+
if (this.currentSipSession && (0, sdp_1.getSipCallId)(this.currentSipSession) !== (0, sdp_1.getSipCallId)(sipSession)) {
|
|
786
789
|
logger.info('WebRTC hold call after resume', {
|
|
787
|
-
id: this.currentSipSession
|
|
790
|
+
id: (0, sdp_1.getSipCallId)(this.currentSipSession),
|
|
788
791
|
});
|
|
789
792
|
this.holdSipSession(this.currentSipSession, this.currentCallSession, withEvent);
|
|
790
793
|
}
|
|
@@ -800,10 +803,10 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
800
803
|
if (!sipSession) {
|
|
801
804
|
return new Promise((resolve, reject) => reject(new Error('No session to hold')));
|
|
802
805
|
}
|
|
803
|
-
const sessionId = (0, sdp_1.
|
|
806
|
+
const sessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
804
807
|
const hasVideo = this.client.hasLocalVideo(sessionId);
|
|
805
808
|
logger.info('WebRTC hold sip session', {
|
|
806
|
-
sipId: sipSession
|
|
809
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
807
810
|
hasVideo,
|
|
808
811
|
});
|
|
809
812
|
// Stop screenshare if needed
|
|
@@ -829,7 +832,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
829
832
|
return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
|
|
830
833
|
}
|
|
831
834
|
const isConference = !!callSession && callSession.isConference();
|
|
832
|
-
const sessionId = (0, sdp_1.
|
|
835
|
+
const sessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
833
836
|
logger.info('WebRTC unhold sip session', {
|
|
834
837
|
sessionId,
|
|
835
838
|
isConference,
|
|
@@ -882,7 +885,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
882
885
|
return;
|
|
883
886
|
}
|
|
884
887
|
logger.info('WebRTC muting', {
|
|
885
|
-
sipId: sipSession
|
|
888
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
886
889
|
});
|
|
887
890
|
this.client.mute(sipSession);
|
|
888
891
|
const newCallSession = this._createCallSession(sipSession, callSession, {
|
|
@@ -904,7 +907,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
904
907
|
return;
|
|
905
908
|
}
|
|
906
909
|
logger.info('WebRTC unmuting', {
|
|
907
|
-
sipId: sipSession
|
|
910
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
908
911
|
});
|
|
909
912
|
this.client.unmute(sipSession);
|
|
910
913
|
const newCallSession = this._createCallSession(sipSession, callSession, {
|
|
@@ -930,7 +933,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
930
933
|
return;
|
|
931
934
|
}
|
|
932
935
|
logger.info('WebRTC turn camera on', {
|
|
933
|
-
sipId: sipSession
|
|
936
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
934
937
|
});
|
|
935
938
|
this.client.toggleCameraOn(sipSession);
|
|
936
939
|
this.eventEmitter.emit(exports.ON_CAMERA_RESUMED, this._createCameraResumedCallSession(sipSession, callSession));
|
|
@@ -941,7 +944,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
941
944
|
return;
|
|
942
945
|
}
|
|
943
946
|
logger.info('WebRTC turn camera off', {
|
|
944
|
-
sipId: sipSession
|
|
947
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
945
948
|
});
|
|
946
949
|
this.client.toggleCameraOff(sipSession);
|
|
947
950
|
this.eventEmitter.emit(exports.ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
|
|
@@ -952,7 +955,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
952
955
|
return;
|
|
953
956
|
}
|
|
954
957
|
logger.info('WebRTC send key', {
|
|
955
|
-
sipId: sipSession
|
|
958
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
956
959
|
tone,
|
|
957
960
|
});
|
|
958
961
|
this.client.sendDTMF(sipSession, tone);
|
|
@@ -1017,7 +1020,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1017
1020
|
return;
|
|
1018
1021
|
}
|
|
1019
1022
|
logger.info('WebRTC transfer', {
|
|
1020
|
-
sipId: sipSession
|
|
1023
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
1021
1024
|
target,
|
|
1022
1025
|
});
|
|
1023
1026
|
this.client.transfer(sipSession, target);
|
|
@@ -1027,8 +1030,8 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1027
1030
|
const sipSession = this.client.getSipSession(source.sipCallId);
|
|
1028
1031
|
const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
|
|
1029
1032
|
logger.info('WebRTC indirect transfer', {
|
|
1030
|
-
sipId: sipSession ? sipSession
|
|
1031
|
-
target: sipSessionTarget ? sipSessionTarget
|
|
1033
|
+
sipId: sipSession ? (0, sdp_1.getSipCallId)(sipSession) : null,
|
|
1034
|
+
target: sipSessionTarget ? (0, sdp_1.getSipCallId)(sipSessionTarget) : null,
|
|
1032
1035
|
});
|
|
1033
1036
|
if (!sipSessionTarget) {
|
|
1034
1037
|
return Promise.reject();
|
|
@@ -1058,9 +1061,9 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1058
1061
|
console.error('Call is unknown to the WebRTC phone', callSession ? callSession.sipCallId : null, callSession ? callSession.callId : null);
|
|
1059
1062
|
return false;
|
|
1060
1063
|
}
|
|
1061
|
-
const sipSessionId = (0, sdp_1.
|
|
1064
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
1062
1065
|
logger.info('WebRTC hangup', {
|
|
1063
|
-
sipId: sipSession
|
|
1066
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
1064
1067
|
sipSessionId,
|
|
1065
1068
|
});
|
|
1066
1069
|
yield this.client.hangup(sipSession);
|
|
@@ -1218,7 +1221,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1218
1221
|
const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
|
|
1219
1222
|
const withVideo = this.allowVideo ? wantsToDoVideo : false;
|
|
1220
1223
|
logger.info('WebRTC invite received', {
|
|
1221
|
-
sipId: sipSession
|
|
1224
|
+
sipId: (0, sdp_1.getSipCallId)(sipSession),
|
|
1222
1225
|
withVideo,
|
|
1223
1226
|
autoAnswer,
|
|
1224
1227
|
});
|
|
@@ -1250,12 +1253,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1250
1253
|
// if `_createCallSession` is called too soon `hasVideo` will return false because the stream doesn't exists yet
|
|
1251
1254
|
setTimeout(() => {
|
|
1252
1255
|
// Update callSession
|
|
1253
|
-
this._createCallSession(sipSession, this.callSessions[(0, sdp_1.
|
|
1256
|
+
this._createCallSession(sipSession, this.callSessions[(0, sdp_1.getSipCallId)(sipSession)]);
|
|
1254
1257
|
this.eventEmitter.emit.apply(this.eventEmitter, [this.client.ON_REINVITE, ...args]);
|
|
1255
1258
|
}, 2000);
|
|
1256
1259
|
});
|
|
1257
1260
|
this.client.on(this.client.ACCEPTED, (sipSession) => __awaiter(this, void 0, void 0, function* () {
|
|
1258
|
-
const sessionId = (0, sdp_1.
|
|
1261
|
+
const sessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
1259
1262
|
const hasSession = (sessionId in this.callSessions);
|
|
1260
1263
|
logger.info('WebRTC call accepted', {
|
|
1261
1264
|
sipId: sessionId,
|
|
@@ -1278,11 +1281,11 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1278
1281
|
this.eventEmitter.emit(exports.ON_CALL_ERROR, e);
|
|
1279
1282
|
});
|
|
1280
1283
|
this.client.on(this.client.REJECTED, session => {
|
|
1281
|
-
logger.info('WebRTC call rejected',
|
|
1284
|
+
logger.info('WebRTC call rejected', { id: (0, sdp_1.getSipCallId)(session) });
|
|
1282
1285
|
const callSession = this._createCallSession(session);
|
|
1283
1286
|
// `_createCallSession` add the CallSession in `this.callSessions`.
|
|
1284
1287
|
// so we have to remove it or `callCount` will always return 1 even if the call was rejected
|
|
1285
|
-
delete this.callSessions[(0, sdp_1.
|
|
1288
|
+
delete this.callSessions[(0, sdp_1.getSipCallId)(session)];
|
|
1286
1289
|
callSession.endTime = new Date();
|
|
1287
1290
|
this.eventEmitter.emit(exports.ON_CALL_REJECTED, callSession);
|
|
1288
1291
|
});
|
|
@@ -1299,7 +1302,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1299
1302
|
const callSession = this._createCallSession(session, null, {
|
|
1300
1303
|
incoming: false,
|
|
1301
1304
|
ringing: true,
|
|
1302
|
-
callId: (0, sdp_1.
|
|
1305
|
+
callId: (0, sdp_1.getSipCallId)(session),
|
|
1303
1306
|
});
|
|
1304
1307
|
this.eventEmitter.emit(exports.ON_PROGRESS, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
1305
1308
|
});
|
|
@@ -1308,7 +1311,7 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1308
1311
|
const callSession = this._createCallSession(session, null, {
|
|
1309
1312
|
incoming: false,
|
|
1310
1313
|
ringing: true,
|
|
1311
|
-
callId: (0, sdp_1.
|
|
1314
|
+
callId: (0, sdp_1.getSipCallId)(session),
|
|
1312
1315
|
});
|
|
1313
1316
|
this.eventEmitter.emit(exports.ON_EARLY_MEDIA, callSession, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
1314
1317
|
});
|
|
@@ -1365,12 +1368,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1365
1368
|
this.eventEmitter.emit(exports.ON_MESSAGE, message);
|
|
1366
1369
|
});
|
|
1367
1370
|
this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
|
|
1368
|
-
const callSession = this.getCallSession((0, sdp_1.
|
|
1371
|
+
const callSession = this.getCallSession((0, sdp_1.getSipCallId)(session));
|
|
1369
1372
|
this.eventEmitter.emit(exports.ON_NETWORK_STATS, callSession, stats, previousStats);
|
|
1370
1373
|
});
|
|
1371
1374
|
// Used when upgrading directly in screenshare mode
|
|
1372
1375
|
this.client.on(this.client.ON_SCREEN_SHARING_REINVITE, (sipSession, response, desktop) => {
|
|
1373
|
-
const sipSessionId = (0, sdp_1.
|
|
1376
|
+
const sipSessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
1374
1377
|
const localStream = this.client.getLocalStream(sipSessionId);
|
|
1375
1378
|
const callSession = this.callSessions[sipSessionId];
|
|
1376
1379
|
logger.info('Updrading directly in screensharing mode', {
|
|
@@ -1382,10 +1385,10 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1382
1385
|
}
|
|
1383
1386
|
// Find a corresponding sipSession from a CallSession
|
|
1384
1387
|
findSipSession(callSession) {
|
|
1385
|
-
const keys = this.client.
|
|
1388
|
+
const keys = this.client.getSipCallIds();
|
|
1386
1389
|
const keyIndex = keys.findIndex(sessionId => callSession && callSession.isId(sessionId));
|
|
1387
1390
|
if (keyIndex === -1) {
|
|
1388
|
-
const currentSipSessionId = this.currentSipSession ? (0, sdp_1.
|
|
1391
|
+
const currentSipSessionId = this.currentSipSession ? (0, sdp_1.getSipCallId)(this.currentSipSession) : this.client.getSipCallIds()[0];
|
|
1389
1392
|
return currentSipSessionId ? this.client.getSipSession(currentSipSessionId) : null;
|
|
1390
1393
|
}
|
|
1391
1394
|
return this.client.getSipSession(keys[keyIndex]);
|
|
@@ -1393,12 +1396,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1393
1396
|
getCallSession(sipSessionId) {
|
|
1394
1397
|
return this.callSessions[sipSessionId];
|
|
1395
1398
|
}
|
|
1396
|
-
|
|
1399
|
+
getSipCallIdFromCallSession(callSession) {
|
|
1397
1400
|
const sipSession = this.findSipSession(callSession);
|
|
1398
|
-
return sipSession ? (0, sdp_1.
|
|
1401
|
+
return sipSession ? (0, sdp_1.getSipCallId)(sipSession) : null;
|
|
1399
1402
|
}
|
|
1400
1403
|
_updateCallSession(callSession) {
|
|
1401
|
-
const sipSessionId = this.
|
|
1404
|
+
const sipSessionId = this.getSipCallIdFromCallSession(callSession);
|
|
1402
1405
|
if (sipSessionId) {
|
|
1403
1406
|
this.callSessions[sipSessionId] = callSession;
|
|
1404
1407
|
}
|
|
@@ -1468,14 +1471,12 @@ class WebRTCPhone extends Emitter_1.default {
|
|
|
1468
1471
|
});
|
|
1469
1472
|
}
|
|
1470
1473
|
_createCallSession(sipSession, fromSession, extra = {}) {
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
const { state, } = sipSession || {};
|
|
1476
|
-
const sessionId = (0, sdp_1.getSipSessionId)(sipSession);
|
|
1474
|
+
const number = (0, sdp_1.getCallNumber)(sipSession);
|
|
1475
|
+
const displayName = (0, sdp_1.getCallDisplayName)(sipSession);
|
|
1476
|
+
const { state } = sipSession || {};
|
|
1477
|
+
const sessionId = (0, sdp_1.getSipCallId)(sipSession);
|
|
1477
1478
|
fromSession = fromSession || this.callSessions[sessionId];
|
|
1478
|
-
const callSession = new CallSession_1.default(Object.assign({ callId: fromSession && fromSession.callId, sipCallId: sessionId, sipStatus: state, displayName
|
|
1479
|
+
const callSession = new CallSession_1.default(Object.assign({ callId: fromSession && fromSession.callId, sipCallId: sessionId, sipStatus: state, displayName,
|
|
1479
1480
|
// @ts-ignore: date / number
|
|
1480
1481
|
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));
|
|
1481
1482
|
this.callSessions[sessionId] = callSession;
|
package/lib/index.js
CHANGED
|
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
exports.SessionDescriptionHandler = exports.ExternalApp = exports.Agent = void 0;
|
|
20
|
+
exports.SOCKET_EVENTS = exports.WebSocketClient = exports.AdHocAPIConference = exports.CallApi = exports.setIsMobile = exports.setOnRefreshTokenError = exports.setOnRefreshToken = exports.setCurrentServer = exports.setApiToken = exports.getApiClient = exports.SipLine = exports.MeetingAuthorization = exports.MeetingStatus = exports.ApiRequester = exports.Checker = exports.DebugDevice = exports.Meeting = exports.CTIPhone = exports.WebRTCPhone = exports.CallerID = exports.SwitchboardCall = exports.IndirectTransfer = exports.CallSession = exports.Room = exports.Relocation = exports.Voicemail = exports.Session = exports.LINE_STATE = exports.PROFILE_STATE = exports.Profile = exports.NotificationOptions = exports.Line = exports.Incall = exports.FORWARD_KEYS = exports.ForwardOption = exports.Features = exports.COUNTRIES = exports.Contact = exports.ChatRoom = exports.ChatMessage = exports.Recording = exports.CallLog = exports.ApiCall = exports.SFUNotAvailableError = exports.InvalidState = exports.InvalidStateTransition = exports.ServerError = exports.BadResponse = exports.IssueReporter = exports.Emitter = void 0;
|
|
21
|
+
exports.Softphone = exports.Call = exports.SessionDescriptionHandler = exports.ExternalApp = exports.Agent = exports.WazoApiClient = exports.WebRTCClient = void 0;
|
|
22
22
|
const index_1 = __importDefault(require("./simple/index"));
|
|
23
23
|
var Emitter_1 = require("./utils/Emitter");
|
|
24
24
|
Object.defineProperty(exports, "Emitter", { enumerable: true, get: function () { return __importDefault(Emitter_1).default; } });
|
|
@@ -28,10 +28,14 @@ var BadResponse_1 = require("./domain/BadResponse");
|
|
|
28
28
|
Object.defineProperty(exports, "BadResponse", { enumerable: true, get: function () { return __importDefault(BadResponse_1).default; } });
|
|
29
29
|
var ServerError_1 = require("./domain/ServerError");
|
|
30
30
|
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return __importDefault(ServerError_1).default; } });
|
|
31
|
+
var InvalidStateTransition_1 = require("./domain/InvalidStateTransition");
|
|
32
|
+
Object.defineProperty(exports, "InvalidStateTransition", { enumerable: true, get: function () { return __importDefault(InvalidStateTransition_1).default; } });
|
|
33
|
+
var InvalidState_1 = require("./domain/InvalidState");
|
|
34
|
+
Object.defineProperty(exports, "InvalidState", { enumerable: true, get: function () { return __importDefault(InvalidState_1).default; } });
|
|
31
35
|
var SFUNotAvailableError_1 = require("./domain/SFUNotAvailableError");
|
|
32
36
|
Object.defineProperty(exports, "SFUNotAvailableError", { enumerable: true, get: function () { return __importDefault(SFUNotAvailableError_1).default; } });
|
|
33
37
|
var Call_1 = require("./domain/Call");
|
|
34
|
-
Object.defineProperty(exports, "
|
|
38
|
+
Object.defineProperty(exports, "ApiCall", { enumerable: true, get: function () { return __importDefault(Call_1).default; } });
|
|
35
39
|
var CallLog_1 = require("./domain/CallLog");
|
|
36
40
|
Object.defineProperty(exports, "CallLog", { enumerable: true, get: function () { return __importDefault(CallLog_1).default; } });
|
|
37
41
|
var Recording_1 = require("./domain/Recording");
|
|
@@ -117,6 +121,10 @@ var ExternalApp_1 = require("./domain/ExternalApp");
|
|
|
117
121
|
Object.defineProperty(exports, "ExternalApp", { enumerable: true, get: function () { return __importDefault(ExternalApp_1).default; } });
|
|
118
122
|
var WazoSessionDescriptionHandler_1 = require("./lib/WazoSessionDescriptionHandler");
|
|
119
123
|
Object.defineProperty(exports, "SessionDescriptionHandler", { enumerable: true, get: function () { return __importDefault(WazoSessionDescriptionHandler_1).default; } });
|
|
124
|
+
var call_1 = require("./voice/call");
|
|
125
|
+
Object.defineProperty(exports, "Call", { enumerable: true, get: function () { return __importDefault(call_1).default; } });
|
|
126
|
+
var softphone_1 = require("./voice/softphone");
|
|
127
|
+
Object.defineProperty(exports, "Softphone", { enumerable: true, get: function () { return softphone_1.Softphone; } });
|
|
120
128
|
__exportStar(require("./types/WebSocketMessage"), exports);
|
|
121
129
|
__exportStar(require("./utils/PhoneNumberUtil"), exports);
|
|
122
130
|
__exportStar(require("./utils/string"), exports);
|
package/lib/service/CallApi.js
CHANGED
|
@@ -51,9 +51,9 @@ class CallApi {
|
|
|
51
51
|
return (0, getApiClient_1.default)().confd.getUserLineSip(session.uuid, lineToUse ? lineToUse.id : '');
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
static cancelCall(
|
|
54
|
+
static cancelCall(call) {
|
|
55
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
return (0, getApiClient_1.default)().calld.cancelCall(
|
|
56
|
+
return (0, getApiClient_1.default)().calld.cancelCall(call.apiId || '');
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
static makeCall(callFromLine_1, extension_1) {
|
package/lib/simple/Auth.js
CHANGED
|
@@ -154,27 +154,26 @@ class Auth {
|
|
|
154
154
|
return this._onAuthenticated(rawSession);
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
|
+
samlLogOut() {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
return yield this.logout(false, true);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
157
162
|
initiateIdpAuthentication(domain, redirectUrl) {
|
|
158
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
let response;
|
|
160
164
|
try {
|
|
161
|
-
|
|
165
|
+
return yield (0, getApiClient_1.default)().auth.initiateIdpAuthentication(domain, redirectUrl);
|
|
162
166
|
}
|
|
163
167
|
catch (e) {
|
|
164
|
-
logger.error('Error during IdP authentication
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!response.ok) {
|
|
168
|
-
if (response.status === 404) {
|
|
169
|
-
throw new NoSamlRouteError('No route found for saml sso');
|
|
168
|
+
logger.error('Error during IdP authentication initialization:', e.message);
|
|
169
|
+
if (e.status === 404) {
|
|
170
|
+
throw new NoSamlRouteError('No route found for SAML SSO');
|
|
170
171
|
}
|
|
171
|
-
if (
|
|
172
|
+
if (e.status === 500) {
|
|
172
173
|
throw new SamlConfigError('SAML/server configuration error');
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
-
throw new Error(error.message || error.reason);
|
|
175
|
+
throw e;
|
|
176
176
|
}
|
|
177
|
-
return response.json();
|
|
178
177
|
});
|
|
179
178
|
}
|
|
180
179
|
logInViaRefreshToken(refreshToken) {
|
|
@@ -212,20 +211,26 @@ class Auth {
|
|
|
212
211
|
});
|
|
213
212
|
}
|
|
214
213
|
logout() {
|
|
215
|
-
return __awaiter(this, arguments, void 0, function* (deleteRefreshToken = true) {
|
|
214
|
+
return __awaiter(this, arguments, void 0, function* (deleteRefreshToken = true, saml = false) {
|
|
216
215
|
var _a;
|
|
217
216
|
try {
|
|
218
217
|
index_1.default.Websocket.close(true);
|
|
219
|
-
if (this.clientId && deleteRefreshToken) {
|
|
218
|
+
if (!saml && this.clientId && deleteRefreshToken) {
|
|
220
219
|
yield (0, getApiClient_1.default)().auth.deleteRefreshToken(this.clientId);
|
|
221
220
|
}
|
|
222
221
|
}
|
|
223
222
|
catch (e) {
|
|
224
223
|
// Nothing to
|
|
225
224
|
}
|
|
225
|
+
let response;
|
|
226
226
|
try {
|
|
227
227
|
if ((_a = this.session) === null || _a === void 0 ? void 0 : _a.token) {
|
|
228
|
-
|
|
228
|
+
if (saml) {
|
|
229
|
+
response = yield (0, getApiClient_1.default)().auth.samlLogOut();
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
yield (0, getApiClient_1.default)().auth.logOut(this.session.token);
|
|
233
|
+
}
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
236
|
catch (e) {
|
|
@@ -237,6 +242,7 @@ class Auth {
|
|
|
237
242
|
this.authenticated = false;
|
|
238
243
|
this.usingEdgeServer = undefined;
|
|
239
244
|
(0, getApiClient_1.setFetchOptions)({});
|
|
245
|
+
return response;
|
|
240
246
|
});
|
|
241
247
|
}
|
|
242
248
|
setOnHostFromHeaders(callback) {
|
package/lib/simple/Phone.js
CHANGED
|
@@ -50,6 +50,7 @@ const logger = IssueReporter_1.default.loggerFor('simple-phone');
|
|
|
50
50
|
const sipLogger = IssueReporter_1.default.loggerFor('sip.js');
|
|
51
51
|
const protocolLogger = IssueReporter_1.default.loggerFor('sip');
|
|
52
52
|
const protocolDebugMessages = ['Received WebSocket text message:', 'Sending WebSocket message:'];
|
|
53
|
+
// @deprecated: Use Wazo.Voice.Softphone instead
|
|
53
54
|
class Phone extends Emitter_1.default {
|
|
54
55
|
constructor() {
|
|
55
56
|
super();
|
|
@@ -236,11 +237,11 @@ class Phone extends Emitter_1.default {
|
|
|
236
237
|
stopNetworkMonitoring(callSession) {
|
|
237
238
|
return this.phone ? this.phone.stopNetworkMonitoring(callSession) : null;
|
|
238
239
|
}
|
|
239
|
-
|
|
240
|
+
getSipCallId(sipSession) {
|
|
240
241
|
if (!sipSession || !this.phone) {
|
|
241
242
|
return null;
|
|
242
243
|
}
|
|
243
|
-
return (0, sdp_1.
|
|
244
|
+
return (0, sdp_1.getSipCallId)(sipSession);
|
|
244
245
|
}
|
|
245
246
|
sendMessage(body, sipSession, contentType = 'text/plain') {
|
|
246
247
|
const toSipSession = sipSession || this.getCurrentSipSession();
|