@wazo/sdk 0.37.26 → 0.37.30
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 +98 -59
- package/dist/wazo-sdk.js +3 -3
- package/esm/__tests__/api-client.test.js +1 -1
- package/esm/__tests__/web-rtc-client.test.js +18 -5
- package/esm/api/agentd.js +1 -1
- package/esm/api/amid.js +1 -1
- package/esm/api/application.js +1 -1
- package/esm/api/auth.js +1 -1
- package/esm/api/call-logd.js +1 -1
- package/esm/api/calld.js +1 -1
- package/esm/api/chatd.js +1 -1
- package/esm/api/confd.js +1 -1
- package/esm/api/ctid-ng.js +1 -1
- package/esm/api/dird.js +1 -1
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +1 -1
- package/esm/checker/Checker.js +18 -5
- package/esm/checker/checks/aor.js +1 -1
- package/esm/checker/checks/api.js +1 -1
- package/esm/checker/checks/index.js +18 -5
- package/esm/checker/checks/wazo-websocket.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +18 -5
- package/esm/checker/checks/webrtc.js +18 -5
- package/esm/domain/AdHocAPIConference.js +1 -1
- package/esm/domain/CallSession.js +29 -2
- package/esm/domain/Features.js +1 -1
- package/esm/domain/Phone/CTIPhone.js +30 -3
- package/esm/domain/Phone/WebRTCPhone.js +55 -6
- package/esm/domain/SFUNotAvailableError.js +9 -0
- package/esm/domain/__tests__/CallSession.test.js +46 -2
- package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
- package/esm/domain/__tests__/Room.test.js +29 -2
- package/esm/index.js +83 -10
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
- package/esm/service/CallApi.js +1 -1
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +1 -1
- package/esm/simple/Auth.js +82 -10
- package/esm/simple/Configuration.js +82 -10
- package/esm/simple/Directory.js +1 -1
- package/esm/simple/Phone.js +82 -10
- package/esm/simple/Websocket.js +1 -1
- package/esm/simple/index.js +82 -10
- package/esm/simple/room/LocalParticipant.js +82 -10
- package/esm/simple/room/Participant.js +82 -10
- package/esm/simple/room/RemoteParticipant.js +82 -10
- package/esm/simple/room/Room.js +82 -10
- package/esm/simple/room/SipRoom.js +82 -10
- package/esm/simple/room/Stream.js +82 -10
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +82 -10
- package/esm/simple/utils.js +82 -10
- package/esm/utils/__tests__/api-requester.test.js +1 -1
- package/esm/utils/api-requester.js +1 -1
- package/esm/web-rtc-client.js +18 -5
- package/esm/websocket-client.js +1 -1
- package/lib/__tests__/api-client.test.js +1 -1
- package/lib/__tests__/web-rtc-client.test.js +18 -5
- package/lib/api/agentd.js +1 -1
- package/lib/api/amid.js +1 -1
- package/lib/api/application.js +1 -1
- package/lib/api/auth.js +1 -1
- package/lib/api/call-logd.js +1 -1
- package/lib/api/calld.js +1 -1
- package/lib/api/chatd.js +1 -1
- package/lib/api/confd.js +1 -1
- package/lib/api/ctid-ng.js +1 -1
- package/lib/api/dird.js +1 -1
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +1 -1
- package/lib/checker/Checker.js +18 -5
- package/lib/checker/checks/aor.js +1 -1
- package/lib/checker/checks/api.js +1 -1
- package/lib/checker/checks/index.js +18 -5
- package/lib/checker/checks/wazo-websocket.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +18 -5
- package/lib/checker/checks/webrtc.js +18 -5
- package/lib/domain/AdHocAPIConference.js +1 -1
- package/lib/domain/CallSession.js +29 -2
- package/lib/domain/Features.js +1 -1
- package/lib/domain/Phone/CTIPhone.js +30 -3
- package/lib/domain/Phone/WebRTCPhone.js +55 -5
- package/lib/domain/SFUNotAvailableError.js +11 -0
- package/lib/domain/__tests__/CallSession.test.js +46 -2
- package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
- package/lib/domain/__tests__/Room.test.js +29 -2
- package/lib/index.js +83 -10
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
- package/lib/service/CallApi.js +1 -1
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +1 -1
- package/lib/simple/Auth.js +82 -10
- package/lib/simple/Configuration.js +82 -10
- package/lib/simple/Directory.js +1 -1
- package/lib/simple/Phone.js +82 -10
- package/lib/simple/Websocket.js +1 -1
- package/lib/simple/index.js +82 -10
- package/lib/simple/room/LocalParticipant.js +82 -10
- package/lib/simple/room/Participant.js +82 -10
- package/lib/simple/room/RemoteParticipant.js +82 -10
- package/lib/simple/room/Room.js +82 -10
- package/lib/simple/room/SipRoom.js +82 -10
- package/lib/simple/room/Stream.js +82 -10
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +82 -10
- package/lib/simple/utils.js +82 -10
- package/lib/utils/__tests__/api-requester.test.js +1 -1
- package/lib/utils/api-requester.js +1 -1
- package/lib/web-rtc-client.js +18 -5
- package/lib/websocket-client.js +1 -1
- package/package.json +1 -1
- package/src/domain/CallSession.js +32 -4
- package/src/domain/Phone/WebRTCPhone.js +24 -2
- package/src/domain/SFUNotAvailableError.js +7 -0
- package/src/domain/__tests__/CallSession.test.js +17 -0
- package/src/index.js +2 -0
- package/src/lib/WazoSessionDescriptionHandler.js +8 -3
- package/src/simple/Phone.js +2 -1
- package/src/simple/index.js +2 -0
- package/src/utils/api-requester.js +1 -1
- package/src/web-rtc-client.js +9 -1
package/lib/simple/Phone.js
CHANGED
|
@@ -258,13 +258,16 @@ var updateFrom = (instance , from ) => {
|
|
|
258
258
|
|
|
259
259
|
|
|
260
260
|
|
|
261
|
+
|
|
261
262
|
|
|
262
263
|
|
|
263
264
|
|
|
264
265
|
|
|
265
266
|
|
|
267
|
+
|
|
266
268
|
|
|
267
269
|
|
|
270
|
+
|
|
268
271
|
|
|
269
272
|
|
|
270
273
|
|
|
@@ -281,6 +284,7 @@ var updateFrom = (instance , from ) => {
|
|
|
281
284
|
|
|
282
285
|
|
|
283
286
|
|
|
287
|
+
|
|
284
288
|
|
|
285
289
|
|
|
286
290
|
class CallSession {
|
|
@@ -300,10 +304,14 @@ class CallSession {
|
|
|
300
304
|
|
|
301
305
|
|
|
302
306
|
|
|
303
|
-
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
// = creationTime
|
|
304
310
|
|
|
305
311
|
|
|
306
312
|
|
|
313
|
+
|
|
314
|
+
|
|
307
315
|
|
|
308
316
|
|
|
309
317
|
|
|
@@ -339,6 +347,8 @@ class CallSession {
|
|
|
339
347
|
|
|
340
348
|
|
|
341
349
|
|
|
350
|
+
|
|
351
|
+
|
|
342
352
|
|
|
343
353
|
constructor({
|
|
344
354
|
answered,
|
|
@@ -352,6 +362,8 @@ class CallSession {
|
|
|
352
362
|
paused,
|
|
353
363
|
ringing,
|
|
354
364
|
startTime,
|
|
365
|
+
creationTime,
|
|
366
|
+
endTime,
|
|
355
367
|
cameraEnabled,
|
|
356
368
|
dialedExtension,
|
|
357
369
|
sipCallId,
|
|
@@ -364,12 +376,16 @@ class CallSession {
|
|
|
364
376
|
recording,
|
|
365
377
|
recordingPaused,
|
|
366
378
|
videoRemotelyDowngraded,
|
|
379
|
+
sipSession,
|
|
380
|
+
answerTime,
|
|
367
381
|
} ) {
|
|
368
382
|
this.callId = callId;
|
|
369
383
|
this.sipCallId = sipCallId;
|
|
370
384
|
this.displayName = displayName;
|
|
371
385
|
this.number = number;
|
|
386
|
+
this.creationTime = creationTime;
|
|
372
387
|
this.startTime = startTime;
|
|
388
|
+
this.endTime = endTime;
|
|
373
389
|
this.isCaller = isCaller;
|
|
374
390
|
this.answered = answered;
|
|
375
391
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -388,6 +404,8 @@ class CallSession {
|
|
|
388
404
|
this.recording = recording || false;
|
|
389
405
|
this.recordingPaused = recordingPaused || false;
|
|
390
406
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
407
|
+
this.sipSession = sipSession;
|
|
408
|
+
this.answerTime = answerTime || this.answerTime;
|
|
391
409
|
|
|
392
410
|
// Useful to compare instead of instanceof with minified code
|
|
393
411
|
this.type = 'CallSession';
|
|
@@ -418,7 +436,7 @@ class CallSession {
|
|
|
418
436
|
}
|
|
419
437
|
|
|
420
438
|
answer() {
|
|
421
|
-
this.
|
|
439
|
+
this.answerTime = new Date();
|
|
422
440
|
}
|
|
423
441
|
|
|
424
442
|
systemAnswer() {
|
|
@@ -574,6 +592,15 @@ class CallSession {
|
|
|
574
592
|
return newFrom(callSession, CallSession);
|
|
575
593
|
}
|
|
576
594
|
|
|
595
|
+
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
596
|
+
set answered(value ) {
|
|
597
|
+
this.answerTime = value ? new Date() : null;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
get answered() {
|
|
601
|
+
return !!this.answerTime;
|
|
602
|
+
}
|
|
603
|
+
|
|
577
604
|
static parseCall(call ) {
|
|
578
605
|
return new CallSession({
|
|
579
606
|
callId: call.id,
|
|
@@ -1038,7 +1065,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
1038
1065
|
|
|
1039
1066
|
// Use a function here to be able to mock it in tests
|
|
1040
1067
|
const realFetch = () => {
|
|
1041
|
-
if (typeof document !== 'undefined') {
|
|
1068
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
1042
1069
|
// Browser
|
|
1043
1070
|
return window.fetch;
|
|
1044
1071
|
}
|
|
@@ -5808,11 +5835,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
5808
5835
|
|
|
5809
5836
|
// $FlowFixMe
|
|
5810
5837
|
setRemoteSessionDescription(sessionDescription ) {
|
|
5811
|
-
|
|
5838
|
+
try {
|
|
5839
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
5812
5840
|
|
|
5813
|
-
|
|
5841
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
5814
5842
|
|
|
5815
|
-
|
|
5843
|
+
return result;
|
|
5844
|
+
} catch (error) {
|
|
5845
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
5846
|
+
throw error;
|
|
5847
|
+
}
|
|
5816
5848
|
}
|
|
5817
5849
|
|
|
5818
5850
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
|
@@ -6351,6 +6383,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6351
6383
|
|
|
6352
6384
|
|
|
6353
6385
|
|
|
6386
|
+
|
|
6354
6387
|
|
|
6355
6388
|
|
|
6356
6389
|
|
|
@@ -7967,6 +8000,13 @@ class WebRTCClient extends Emitter {
|
|
|
7967
8000
|
}
|
|
7968
8001
|
|
|
7969
8002
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8003
|
+
let { host } = this.config;
|
|
8004
|
+
let port = this.config.port || 443;
|
|
8005
|
+
|
|
8006
|
+
if (this.config.websocketSip) {
|
|
8007
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8008
|
+
}
|
|
8009
|
+
|
|
7970
8010
|
const config = {
|
|
7971
8011
|
authorizationUsername: this.config.authorizationUser,
|
|
7972
8012
|
authorizationPassword: this.config.password,
|
|
@@ -8002,7 +8042,7 @@ class WebRTCClient extends Emitter {
|
|
|
8002
8042
|
},
|
|
8003
8043
|
transportOptions: {
|
|
8004
8044
|
traceSip: configOverrides.traceSip || false,
|
|
8005
|
-
wsServers: `wss://${
|
|
8045
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8006
8046
|
},
|
|
8007
8047
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8008
8048
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8464,6 +8504,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
8464
8504
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
8465
8505
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
8466
8506
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
8507
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
8467
8508
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8468
8509
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8469
8510
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -8508,6 +8549,7 @@ const events = [
|
|
|
8508
8549
|
ON_CAMERA_DISABLED,
|
|
8509
8550
|
ON_CALL_FAILED,
|
|
8510
8551
|
ON_CALL_ENDED,
|
|
8552
|
+
ON_CALL_REJECTED,
|
|
8511
8553
|
ON_MESSAGE,
|
|
8512
8554
|
ON_REINVITE,
|
|
8513
8555
|
ON_TRACK,
|
|
@@ -8864,6 +8906,7 @@ class WebRTCPhone extends Emitter {
|
|
|
8864
8906
|
|
|
8865
8907
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
8866
8908
|
const callSession = this._createCallSession(sipSession);
|
|
8909
|
+
callSession.endTime = new Date();
|
|
8867
8910
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
8868
8911
|
|
|
8869
8912
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -9059,6 +9102,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9059
9102
|
this.removeIncomingSessions(sipSessionId);
|
|
9060
9103
|
}
|
|
9061
9104
|
|
|
9105
|
+
callSession.answerTime = new Date();
|
|
9062
9106
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9063
9107
|
|
|
9064
9108
|
return callSession;
|
|
@@ -9116,6 +9160,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9116
9160
|
_onCallTerminated(sipSession ) {
|
|
9117
9161
|
logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9118
9162
|
|
|
9163
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9119
9164
|
const callSession = this._createCallSession(sipSession);
|
|
9120
9165
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9121
9166
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9133,7 +9178,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9133
9178
|
}, 5);
|
|
9134
9179
|
}
|
|
9135
9180
|
|
|
9136
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9137
9181
|
if (sipSessionId) {
|
|
9138
9182
|
this.removeIncomingSessions(sipSessionId);
|
|
9139
9183
|
}
|
|
@@ -9274,6 +9318,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9274
9318
|
}
|
|
9275
9319
|
|
|
9276
9320
|
this.shouldSendReinvite = false;
|
|
9321
|
+
callSession.answerTime = new Date();
|
|
9277
9322
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9278
9323
|
|
|
9279
9324
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9583,6 +9628,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9583
9628
|
return Promise.resolve(null);
|
|
9584
9629
|
}
|
|
9585
9630
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9631
|
+
callSession.creationTime = new Date();
|
|
9586
9632
|
|
|
9587
9633
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9588
9634
|
|
|
@@ -9778,8 +9824,12 @@ class WebRTCPhone extends Emitter {
|
|
|
9778
9824
|
}
|
|
9779
9825
|
|
|
9780
9826
|
const sessionId = this.incomingSessions[0];
|
|
9827
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
9828
|
+
if (!sipSession) {
|
|
9829
|
+
return null;
|
|
9830
|
+
}
|
|
9781
9831
|
|
|
9782
|
-
return this._createCallSession(
|
|
9832
|
+
return this._createCallSession(sipSession);
|
|
9783
9833
|
}
|
|
9784
9834
|
|
|
9785
9835
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -9857,6 +9907,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9857
9907
|
callSession);
|
|
9858
9908
|
}
|
|
9859
9909
|
|
|
9910
|
+
callSession.creationTime = new Date();
|
|
9860
9911
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
9861
9912
|
});
|
|
9862
9913
|
|
|
@@ -9896,6 +9947,13 @@ class WebRTCPhone extends Emitter {
|
|
|
9896
9947
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
9897
9948
|
});
|
|
9898
9949
|
|
|
9950
|
+
this.client.on(this.client.REJECTED, session => {
|
|
9951
|
+
logger$8.info('WebRTC call rejected', session.id);
|
|
9952
|
+
const callSession = this._createCallSession(session);
|
|
9953
|
+
callSession.endTime = new Date();
|
|
9954
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
9955
|
+
});
|
|
9956
|
+
|
|
9899
9957
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
9900
9958
|
logger$8.info('WebRTC unregistered');
|
|
9901
9959
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
@@ -10108,6 +10166,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10108
10166
|
const number = identity ? identity.uri._normal.user : null;
|
|
10109
10167
|
const { state } = sipSession || {};
|
|
10110
10168
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10169
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
10111
10170
|
|
|
10112
10171
|
const callSession = new CallSession({
|
|
10113
10172
|
callId: fromSession && fromSession.callId,
|
|
@@ -10115,6 +10174,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10115
10174
|
sipStatus: state,
|
|
10116
10175
|
displayName: identity ? identity.displayName || number : number,
|
|
10117
10176
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10177
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10178
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
10118
10179
|
answered: state === sessionState.SessionState.Established,
|
|
10119
10180
|
paused: this.client.isCallHeld(sipSession),
|
|
10120
10181
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -10125,6 +10186,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10125
10186
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
10126
10187
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
10127
10188
|
recordingPaused: false, // @TODO
|
|
10189
|
+
sipSession,
|
|
10128
10190
|
...extra,
|
|
10129
10191
|
});
|
|
10130
10192
|
|
|
@@ -10153,6 +10215,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10153
10215
|
ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
|
|
10154
10216
|
ON_CALL_CANCELED: ON_CALL_CANCELED,
|
|
10155
10217
|
ON_CALL_FAILED: ON_CALL_FAILED,
|
|
10218
|
+
ON_CALL_REJECTED: ON_CALL_REJECTED,
|
|
10156
10219
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10157
10220
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10158
10221
|
ON_MESSAGE: ON_MESSAGE,
|
|
@@ -12432,6 +12495,14 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
|
|
|
12432
12495
|
|
|
12433
12496
|
const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
|
|
12434
12497
|
|
|
12498
|
+
/* */
|
|
12499
|
+
class SFUNotAvailableError extends Error {
|
|
12500
|
+
constructor(message = 'Sorry your user is not configured to support video conference') {
|
|
12501
|
+
super(message);
|
|
12502
|
+
this.name = 'SFUNotAvailableError';
|
|
12503
|
+
}
|
|
12504
|
+
}
|
|
12505
|
+
|
|
12435
12506
|
//
|
|
12436
12507
|
|
|
12437
12508
|
|
|
@@ -13333,6 +13404,7 @@ const Wazo = {
|
|
|
13333
13404
|
InvalidSubscription,
|
|
13334
13405
|
InvalidAuthorization,
|
|
13335
13406
|
CanceledCallError,
|
|
13407
|
+
SFUNotAvailableError,
|
|
13336
13408
|
};
|
|
13337
13409
|
|
|
13338
13410
|
if (window) {
|
|
@@ -13726,7 +13798,7 @@ class Phone extends Emitter {
|
|
|
13726
13798
|
|
|
13727
13799
|
checkSfu() {
|
|
13728
13800
|
if (!this.hasSfu()) {
|
|
13729
|
-
throw new
|
|
13801
|
+
throw new SFUNotAvailableError();
|
|
13730
13802
|
}
|
|
13731
13803
|
}
|
|
13732
13804
|
|
package/lib/simple/Websocket.js
CHANGED
|
@@ -47,7 +47,7 @@ IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
47
47
|
|
|
48
48
|
// Use a function here to be able to mock it in tests
|
|
49
49
|
const realFetch = () => {
|
|
50
|
-
if (typeof document !== 'undefined') {
|
|
50
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
51
51
|
// Browser
|
|
52
52
|
return window.fetch;
|
|
53
53
|
}
|
package/lib/simple/index.js
CHANGED
|
@@ -1961,7 +1961,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
1961
1961
|
|
|
1962
1962
|
// Use a function here to be able to mock it in tests
|
|
1963
1963
|
const realFetch = () => {
|
|
1964
|
-
if (typeof document !== 'undefined') {
|
|
1964
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
1965
1965
|
// Browser
|
|
1966
1966
|
return window.fetch;
|
|
1967
1967
|
}
|
|
@@ -3258,13 +3258,16 @@ var updateFrom = (instance , from ) => {
|
|
|
3258
3258
|
|
|
3259
3259
|
|
|
3260
3260
|
|
|
3261
|
+
|
|
3261
3262
|
|
|
3262
3263
|
|
|
3263
3264
|
|
|
3264
3265
|
|
|
3265
3266
|
|
|
3267
|
+
|
|
3266
3268
|
|
|
3267
3269
|
|
|
3270
|
+
|
|
3268
3271
|
|
|
3269
3272
|
|
|
3270
3273
|
|
|
@@ -3281,6 +3284,7 @@ var updateFrom = (instance , from ) => {
|
|
|
3281
3284
|
|
|
3282
3285
|
|
|
3283
3286
|
|
|
3287
|
+
|
|
3284
3288
|
|
|
3285
3289
|
|
|
3286
3290
|
class CallSession {
|
|
@@ -3300,10 +3304,14 @@ class CallSession {
|
|
|
3300
3304
|
|
|
3301
3305
|
|
|
3302
3306
|
|
|
3303
|
-
|
|
3307
|
+
|
|
3308
|
+
|
|
3309
|
+
// = creationTime
|
|
3304
3310
|
|
|
3305
3311
|
|
|
3306
3312
|
|
|
3313
|
+
|
|
3314
|
+
|
|
3307
3315
|
|
|
3308
3316
|
|
|
3309
3317
|
|
|
@@ -3339,6 +3347,8 @@ class CallSession {
|
|
|
3339
3347
|
|
|
3340
3348
|
|
|
3341
3349
|
|
|
3350
|
+
|
|
3351
|
+
|
|
3342
3352
|
|
|
3343
3353
|
constructor({
|
|
3344
3354
|
answered,
|
|
@@ -3352,6 +3362,8 @@ class CallSession {
|
|
|
3352
3362
|
paused,
|
|
3353
3363
|
ringing,
|
|
3354
3364
|
startTime,
|
|
3365
|
+
creationTime,
|
|
3366
|
+
endTime,
|
|
3355
3367
|
cameraEnabled,
|
|
3356
3368
|
dialedExtension,
|
|
3357
3369
|
sipCallId,
|
|
@@ -3364,12 +3376,16 @@ class CallSession {
|
|
|
3364
3376
|
recording,
|
|
3365
3377
|
recordingPaused,
|
|
3366
3378
|
videoRemotelyDowngraded,
|
|
3379
|
+
sipSession,
|
|
3380
|
+
answerTime,
|
|
3367
3381
|
} ) {
|
|
3368
3382
|
this.callId = callId;
|
|
3369
3383
|
this.sipCallId = sipCallId;
|
|
3370
3384
|
this.displayName = displayName;
|
|
3371
3385
|
this.number = number;
|
|
3386
|
+
this.creationTime = creationTime;
|
|
3372
3387
|
this.startTime = startTime;
|
|
3388
|
+
this.endTime = endTime;
|
|
3373
3389
|
this.isCaller = isCaller;
|
|
3374
3390
|
this.answered = answered;
|
|
3375
3391
|
this.answeredBySystem = answeredBySystem;
|
|
@@ -3388,6 +3404,8 @@ class CallSession {
|
|
|
3388
3404
|
this.recording = recording || false;
|
|
3389
3405
|
this.recordingPaused = recordingPaused || false;
|
|
3390
3406
|
this.videoRemotelyDowngraded = videoRemotelyDowngraded;
|
|
3407
|
+
this.sipSession = sipSession;
|
|
3408
|
+
this.answerTime = answerTime || this.answerTime;
|
|
3391
3409
|
|
|
3392
3410
|
// Useful to compare instead of instanceof with minified code
|
|
3393
3411
|
this.type = 'CallSession';
|
|
@@ -3418,7 +3436,7 @@ class CallSession {
|
|
|
3418
3436
|
}
|
|
3419
3437
|
|
|
3420
3438
|
answer() {
|
|
3421
|
-
this.
|
|
3439
|
+
this.answerTime = new Date();
|
|
3422
3440
|
}
|
|
3423
3441
|
|
|
3424
3442
|
systemAnswer() {
|
|
@@ -3574,6 +3592,15 @@ class CallSession {
|
|
|
3574
3592
|
return newFrom(callSession, CallSession);
|
|
3575
3593
|
}
|
|
3576
3594
|
|
|
3595
|
+
// Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
|
|
3596
|
+
set answered(value ) {
|
|
3597
|
+
this.answerTime = value ? new Date() : null;
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3600
|
+
get answered() {
|
|
3601
|
+
return !!this.answerTime;
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3577
3604
|
static parseCall(call ) {
|
|
3578
3605
|
return new CallSession({
|
|
3579
3606
|
callId: call.id,
|
|
@@ -6072,11 +6099,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
|
|
|
6072
6099
|
|
|
6073
6100
|
// $FlowFixMe
|
|
6074
6101
|
setRemoteSessionDescription(sessionDescription ) {
|
|
6075
|
-
|
|
6102
|
+
try {
|
|
6103
|
+
const result = super.setRemoteSessionDescription(sessionDescription);
|
|
6076
6104
|
|
|
6077
|
-
|
|
6105
|
+
this.eventEmitter.emit('setDescription', sessionDescription);
|
|
6078
6106
|
|
|
6079
|
-
|
|
6107
|
+
return result;
|
|
6108
|
+
} catch (error) {
|
|
6109
|
+
this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
|
|
6110
|
+
throw error;
|
|
6111
|
+
}
|
|
6080
6112
|
}
|
|
6081
6113
|
|
|
6082
6114
|
// Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
|
|
@@ -6615,6 +6647,7 @@ const MAX_REGISTER_TRIES = 10;
|
|
|
6615
6647
|
|
|
6616
6648
|
|
|
6617
6649
|
|
|
6650
|
+
|
|
6618
6651
|
|
|
6619
6652
|
|
|
6620
6653
|
|
|
@@ -8231,6 +8264,13 @@ class WebRTCClient extends Emitter {
|
|
|
8231
8264
|
}
|
|
8232
8265
|
|
|
8233
8266
|
_createWebRTCConfiguration(configOverrides = {}) {
|
|
8267
|
+
let { host } = this.config;
|
|
8268
|
+
let port = this.config.port || 443;
|
|
8269
|
+
|
|
8270
|
+
if (this.config.websocketSip) {
|
|
8271
|
+
[host, port = 443] = this.config.websocketSip.split(':');
|
|
8272
|
+
}
|
|
8273
|
+
|
|
8234
8274
|
const config = {
|
|
8235
8275
|
authorizationUsername: this.config.authorizationUser,
|
|
8236
8276
|
authorizationPassword: this.config.password,
|
|
@@ -8266,7 +8306,7 @@ class WebRTCClient extends Emitter {
|
|
|
8266
8306
|
},
|
|
8267
8307
|
transportOptions: {
|
|
8268
8308
|
traceSip: configOverrides.traceSip || false,
|
|
8269
|
-
wsServers: `wss://${
|
|
8309
|
+
wsServers: `wss://${host}:${port}/api/asterisk/ws`,
|
|
8270
8310
|
},
|
|
8271
8311
|
sessionDescriptionHandlerFactoryOptions: {
|
|
8272
8312
|
modifiers: [replaceLocalIpModifier],
|
|
@@ -8728,6 +8768,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
8728
8768
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
8729
8769
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
8730
8770
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
8771
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
8731
8772
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8732
8773
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8733
8774
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -8772,6 +8813,7 @@ const events = [
|
|
|
8772
8813
|
ON_CAMERA_DISABLED,
|
|
8773
8814
|
ON_CALL_FAILED,
|
|
8774
8815
|
ON_CALL_ENDED,
|
|
8816
|
+
ON_CALL_REJECTED,
|
|
8775
8817
|
ON_MESSAGE,
|
|
8776
8818
|
ON_REINVITE,
|
|
8777
8819
|
ON_TRACK,
|
|
@@ -9128,6 +9170,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9128
9170
|
|
|
9129
9171
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9130
9172
|
const callSession = this._createCallSession(sipSession);
|
|
9173
|
+
callSession.endTime = new Date();
|
|
9131
9174
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9132
9175
|
|
|
9133
9176
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -9323,6 +9366,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9323
9366
|
this.removeIncomingSessions(sipSessionId);
|
|
9324
9367
|
}
|
|
9325
9368
|
|
|
9369
|
+
callSession.answerTime = new Date();
|
|
9326
9370
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9327
9371
|
|
|
9328
9372
|
return callSession;
|
|
@@ -9380,6 +9424,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9380
9424
|
_onCallTerminated(sipSession ) {
|
|
9381
9425
|
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9382
9426
|
|
|
9427
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9383
9428
|
const callSession = this._createCallSession(sipSession);
|
|
9384
9429
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9385
9430
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9397,7 +9442,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9397
9442
|
}, 5);
|
|
9398
9443
|
}
|
|
9399
9444
|
|
|
9400
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9401
9445
|
if (sipSessionId) {
|
|
9402
9446
|
this.removeIncomingSessions(sipSessionId);
|
|
9403
9447
|
}
|
|
@@ -9538,6 +9582,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9538
9582
|
}
|
|
9539
9583
|
|
|
9540
9584
|
this.shouldSendReinvite = false;
|
|
9585
|
+
callSession.answerTime = new Date();
|
|
9541
9586
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9542
9587
|
|
|
9543
9588
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9847,6 +9892,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9847
9892
|
return Promise.resolve(null);
|
|
9848
9893
|
}
|
|
9849
9894
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9895
|
+
callSession.creationTime = new Date();
|
|
9850
9896
|
|
|
9851
9897
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9852
9898
|
|
|
@@ -10042,8 +10088,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10042
10088
|
}
|
|
10043
10089
|
|
|
10044
10090
|
const sessionId = this.incomingSessions[0];
|
|
10091
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
10092
|
+
if (!sipSession) {
|
|
10093
|
+
return null;
|
|
10094
|
+
}
|
|
10045
10095
|
|
|
10046
|
-
return this._createCallSession(
|
|
10096
|
+
return this._createCallSession(sipSession);
|
|
10047
10097
|
}
|
|
10048
10098
|
|
|
10049
10099
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -10121,6 +10171,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10121
10171
|
callSession);
|
|
10122
10172
|
}
|
|
10123
10173
|
|
|
10174
|
+
callSession.creationTime = new Date();
|
|
10124
10175
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10125
10176
|
});
|
|
10126
10177
|
|
|
@@ -10160,6 +10211,13 @@ class WebRTCPhone extends Emitter {
|
|
|
10160
10211
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10161
10212
|
});
|
|
10162
10213
|
|
|
10214
|
+
this.client.on(this.client.REJECTED, session => {
|
|
10215
|
+
logger$7.info('WebRTC call rejected', session.id);
|
|
10216
|
+
const callSession = this._createCallSession(session);
|
|
10217
|
+
callSession.endTime = new Date();
|
|
10218
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10219
|
+
});
|
|
10220
|
+
|
|
10163
10221
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10164
10222
|
logger$7.info('WebRTC unregistered');
|
|
10165
10223
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
@@ -10372,6 +10430,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10372
10430
|
const number = identity ? identity.uri._normal.user : null;
|
|
10373
10431
|
const { state } = sipSession || {};
|
|
10374
10432
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10433
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
10375
10434
|
|
|
10376
10435
|
const callSession = new CallSession({
|
|
10377
10436
|
callId: fromSession && fromSession.callId,
|
|
@@ -10379,6 +10438,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10379
10438
|
sipStatus: state,
|
|
10380
10439
|
displayName: identity ? identity.displayName || number : number,
|
|
10381
10440
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10441
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10442
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
10382
10443
|
answered: state === sessionState.SessionState.Established,
|
|
10383
10444
|
paused: this.client.isCallHeld(sipSession),
|
|
10384
10445
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -10389,6 +10450,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10389
10450
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
10390
10451
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
10391
10452
|
recordingPaused: false, // @TODO
|
|
10453
|
+
sipSession,
|
|
10392
10454
|
...extra,
|
|
10393
10455
|
});
|
|
10394
10456
|
|
|
@@ -10417,6 +10479,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10417
10479
|
ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
|
|
10418
10480
|
ON_CALL_CANCELED: ON_CALL_CANCELED,
|
|
10419
10481
|
ON_CALL_FAILED: ON_CALL_FAILED,
|
|
10482
|
+
ON_CALL_REJECTED: ON_CALL_REJECTED,
|
|
10420
10483
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10421
10484
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10422
10485
|
ON_MESSAGE: ON_MESSAGE,
|
|
@@ -10446,6 +10509,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10446
10509
|
'default': WebRTCPhone
|
|
10447
10510
|
});
|
|
10448
10511
|
|
|
10512
|
+
/* */
|
|
10513
|
+
class SFUNotAvailableError extends Error {
|
|
10514
|
+
constructor(message = 'Sorry your user is not configured to support video conference') {
|
|
10515
|
+
super(message);
|
|
10516
|
+
this.name = 'SFUNotAvailableError';
|
|
10517
|
+
}
|
|
10518
|
+
}
|
|
10519
|
+
|
|
10449
10520
|
//
|
|
10450
10521
|
|
|
10451
10522
|
const logger$6 = IssueReporter$1.loggerFor('simple-phone');
|
|
@@ -10830,7 +10901,7 @@ class Phone extends Emitter {
|
|
|
10830
10901
|
|
|
10831
10902
|
checkSfu() {
|
|
10832
10903
|
if (!this.hasSfu()) {
|
|
10833
|
-
throw new
|
|
10904
|
+
throw new SFUNotAvailableError();
|
|
10834
10905
|
}
|
|
10835
10906
|
}
|
|
10836
10907
|
|
|
@@ -13743,6 +13814,7 @@ const Wazo = {
|
|
|
13743
13814
|
InvalidSubscription,
|
|
13744
13815
|
InvalidAuthorization,
|
|
13745
13816
|
CanceledCallError,
|
|
13817
|
+
SFUNotAvailableError,
|
|
13746
13818
|
};
|
|
13747
13819
|
|
|
13748
13820
|
if (window) {
|