@wazo/sdk 0.37.25 → 0.37.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -58
- package/dist/wazo-sdk.js +3 -3
- package/esm/__tests__/api-client.test.js +2 -2
- package/esm/__tests__/web-rtc-client.test.js +10 -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 +2 -2
- package/esm/api/webhookd.js +1 -1
- package/esm/api-client.js +2 -2
- package/esm/checker/Checker.js +10 -5
- package/esm/checker/checks/aor.js +2 -2
- package/esm/checker/checks/api.js +2 -2
- package/esm/checker/checks/index.js +10 -5
- package/esm/checker/checks/wazo-websocket.js +1 -1
- package/esm/checker/checks/webrtc-transport.js +10 -5
- package/esm/checker/checks/webrtc.js +10 -5
- package/esm/domain/AdHocAPIConference.js +2 -2
- package/esm/domain/CallSession.js +29 -2
- package/esm/domain/Contact.js +1 -1
- package/esm/domain/Features.js +2 -2
- package/esm/domain/Phone/CTIPhone.js +31 -4
- 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__/Contact.test.js +1 -1
- package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
- package/esm/domain/__tests__/Room.test.js +29 -2
- package/esm/index.js +75 -10
- package/esm/lib/WazoSessionDescriptionHandler.js +9 -4
- package/esm/service/CallApi.js +2 -2
- package/esm/service/IssueReporter.js +1 -1
- package/esm/service/__tests__/IssueReporter.test.js +1 -1
- package/esm/service/getApiClient.js +2 -2
- package/esm/simple/Auth.js +74 -10
- package/esm/simple/Configuration.js +74 -10
- package/esm/simple/Directory.js +2 -2
- package/esm/simple/Phone.js +74 -10
- package/esm/simple/Websocket.js +1 -1
- package/esm/simple/index.js +74 -10
- package/esm/simple/room/LocalParticipant.js +74 -10
- package/esm/simple/room/Participant.js +74 -10
- package/esm/simple/room/RemoteParticipant.js +74 -10
- package/esm/simple/room/Room.js +74 -10
- package/esm/simple/room/SipRoom.js +74 -10
- package/esm/simple/room/Stream.js +74 -10
- package/esm/simple/room/__tests__/RemoteParticipant.test.js +74 -10
- package/esm/simple/utils.js +74 -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 +10 -5
- package/esm/websocket-client.js +1 -1
- package/lib/__tests__/api-client.test.js +2 -2
- package/lib/__tests__/web-rtc-client.test.js +10 -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 +2 -2
- package/lib/api/webhookd.js +1 -1
- package/lib/api-client.js +2 -2
- package/lib/checker/Checker.js +10 -5
- package/lib/checker/checks/aor.js +2 -2
- package/lib/checker/checks/api.js +2 -2
- package/lib/checker/checks/index.js +10 -5
- package/lib/checker/checks/wazo-websocket.js +1 -1
- package/lib/checker/checks/webrtc-transport.js +10 -5
- package/lib/checker/checks/webrtc.js +10 -5
- package/lib/domain/AdHocAPIConference.js +2 -2
- package/lib/domain/CallSession.js +29 -2
- package/lib/domain/Contact.js +1 -1
- package/lib/domain/Features.js +2 -2
- package/lib/domain/Phone/CTIPhone.js +31 -4
- 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__/Contact.test.js +1 -1
- package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
- package/lib/domain/__tests__/Room.test.js +29 -2
- package/lib/index.js +75 -10
- package/lib/lib/WazoSessionDescriptionHandler.js +9 -4
- package/lib/service/CallApi.js +2 -2
- package/lib/service/IssueReporter.js +1 -1
- package/lib/service/__tests__/IssueReporter.test.js +1 -1
- package/lib/service/getApiClient.js +2 -2
- package/lib/simple/Auth.js +74 -10
- package/lib/simple/Configuration.js +74 -10
- package/lib/simple/Directory.js +2 -2
- package/lib/simple/Phone.js +74 -10
- package/lib/simple/Websocket.js +1 -1
- package/lib/simple/index.js +74 -10
- package/lib/simple/room/LocalParticipant.js +74 -10
- package/lib/simple/room/Participant.js +74 -10
- package/lib/simple/room/RemoteParticipant.js +74 -10
- package/lib/simple/room/Room.js +74 -10
- package/lib/simple/room/SipRoom.js +74 -10
- package/lib/simple/room/Stream.js +74 -10
- package/lib/simple/room/__tests__/RemoteParticipant.test.js +74 -10
- package/lib/simple/utils.js +74 -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 +10 -5
- package/lib/websocket-client.js +1 -1
- package/package.json +1 -1
- package/src/domain/CallSession.js +32 -4
- package/src/domain/Contact.js +1 -1
- 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
|
@@ -116,7 +116,7 @@ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
|
|
|
116
116
|
|
|
117
117
|
// Use a function here to be able to mock it in tests
|
|
118
118
|
const realFetch = () => {
|
|
119
|
-
if (typeof document !== 'undefined') {
|
|
119
|
+
if (typeof document !== 'undefined' && window.fetch) {
|
|
120
120
|
// Browser
|
|
121
121
|
return window.fetch;
|
|
122
122
|
}
|
|
@@ -1933,7 +1933,7 @@ class Contact {
|
|
|
1933
1933
|
this[key] = old[key] || this[key];
|
|
1934
1934
|
});
|
|
1935
1935
|
|
|
1936
|
-
if (old.lineState
|
|
1936
|
+
if (old.lineState) {
|
|
1937
1937
|
this.lineState = old.lineState;
|
|
1938
1938
|
}
|
|
1939
1939
|
|
|
@@ -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.
|
|
@@ -8728,6 +8760,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
8728
8760
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
8729
8761
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
8730
8762
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
8763
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
8731
8764
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8732
8765
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8733
8766
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -8772,6 +8805,7 @@ const events = [
|
|
|
8772
8805
|
ON_CAMERA_DISABLED,
|
|
8773
8806
|
ON_CALL_FAILED,
|
|
8774
8807
|
ON_CALL_ENDED,
|
|
8808
|
+
ON_CALL_REJECTED,
|
|
8775
8809
|
ON_MESSAGE,
|
|
8776
8810
|
ON_REINVITE,
|
|
8777
8811
|
ON_TRACK,
|
|
@@ -9128,6 +9162,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9128
9162
|
|
|
9129
9163
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9130
9164
|
const callSession = this._createCallSession(sipSession);
|
|
9165
|
+
callSession.endTime = new Date();
|
|
9131
9166
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9132
9167
|
|
|
9133
9168
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -9323,6 +9358,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9323
9358
|
this.removeIncomingSessions(sipSessionId);
|
|
9324
9359
|
}
|
|
9325
9360
|
|
|
9361
|
+
callSession.answerTime = new Date();
|
|
9326
9362
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9327
9363
|
|
|
9328
9364
|
return callSession;
|
|
@@ -9380,6 +9416,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9380
9416
|
_onCallTerminated(sipSession ) {
|
|
9381
9417
|
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9382
9418
|
|
|
9419
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9383
9420
|
const callSession = this._createCallSession(sipSession);
|
|
9384
9421
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9385
9422
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9397,7 +9434,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9397
9434
|
}, 5);
|
|
9398
9435
|
}
|
|
9399
9436
|
|
|
9400
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9401
9437
|
if (sipSessionId) {
|
|
9402
9438
|
this.removeIncomingSessions(sipSessionId);
|
|
9403
9439
|
}
|
|
@@ -9538,6 +9574,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9538
9574
|
}
|
|
9539
9575
|
|
|
9540
9576
|
this.shouldSendReinvite = false;
|
|
9577
|
+
callSession.answerTime = new Date();
|
|
9541
9578
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9542
9579
|
|
|
9543
9580
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9847,6 +9884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9847
9884
|
return Promise.resolve(null);
|
|
9848
9885
|
}
|
|
9849
9886
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9887
|
+
callSession.creationTime = new Date();
|
|
9850
9888
|
|
|
9851
9889
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9852
9890
|
|
|
@@ -10042,8 +10080,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10042
10080
|
}
|
|
10043
10081
|
|
|
10044
10082
|
const sessionId = this.incomingSessions[0];
|
|
10083
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
10084
|
+
if (!sipSession) {
|
|
10085
|
+
return null;
|
|
10086
|
+
}
|
|
10045
10087
|
|
|
10046
|
-
return this._createCallSession(
|
|
10088
|
+
return this._createCallSession(sipSession);
|
|
10047
10089
|
}
|
|
10048
10090
|
|
|
10049
10091
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -10121,6 +10163,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10121
10163
|
callSession);
|
|
10122
10164
|
}
|
|
10123
10165
|
|
|
10166
|
+
callSession.creationTime = new Date();
|
|
10124
10167
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10125
10168
|
});
|
|
10126
10169
|
|
|
@@ -10160,6 +10203,13 @@ class WebRTCPhone extends Emitter {
|
|
|
10160
10203
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10161
10204
|
});
|
|
10162
10205
|
|
|
10206
|
+
this.client.on(this.client.REJECTED, session => {
|
|
10207
|
+
logger$7.info('WebRTC call rejected', session.id);
|
|
10208
|
+
const callSession = this._createCallSession(session);
|
|
10209
|
+
callSession.endTime = new Date();
|
|
10210
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10211
|
+
});
|
|
10212
|
+
|
|
10163
10213
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10164
10214
|
logger$7.info('WebRTC unregistered');
|
|
10165
10215
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
@@ -10372,6 +10422,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10372
10422
|
const number = identity ? identity.uri._normal.user : null;
|
|
10373
10423
|
const { state } = sipSession || {};
|
|
10374
10424
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10425
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
10375
10426
|
|
|
10376
10427
|
const callSession = new CallSession({
|
|
10377
10428
|
callId: fromSession && fromSession.callId,
|
|
@@ -10379,6 +10430,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10379
10430
|
sipStatus: state,
|
|
10380
10431
|
displayName: identity ? identity.displayName || number : number,
|
|
10381
10432
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10433
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10434
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
10382
10435
|
answered: state === sessionState.SessionState.Established,
|
|
10383
10436
|
paused: this.client.isCallHeld(sipSession),
|
|
10384
10437
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -10389,6 +10442,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10389
10442
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
10390
10443
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
10391
10444
|
recordingPaused: false, // @TODO
|
|
10445
|
+
sipSession,
|
|
10392
10446
|
...extra,
|
|
10393
10447
|
});
|
|
10394
10448
|
|
|
@@ -10417,6 +10471,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10417
10471
|
ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
|
|
10418
10472
|
ON_CALL_CANCELED: ON_CALL_CANCELED,
|
|
10419
10473
|
ON_CALL_FAILED: ON_CALL_FAILED,
|
|
10474
|
+
ON_CALL_REJECTED: ON_CALL_REJECTED,
|
|
10420
10475
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10421
10476
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10422
10477
|
ON_MESSAGE: ON_MESSAGE,
|
|
@@ -10446,6 +10501,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10446
10501
|
'default': WebRTCPhone
|
|
10447
10502
|
});
|
|
10448
10503
|
|
|
10504
|
+
/* */
|
|
10505
|
+
class SFUNotAvailableError extends Error {
|
|
10506
|
+
constructor(message = 'Sorry your user is not configured to support video conference') {
|
|
10507
|
+
super(message);
|
|
10508
|
+
this.name = 'SFUNotAvailableError';
|
|
10509
|
+
}
|
|
10510
|
+
}
|
|
10511
|
+
|
|
10449
10512
|
//
|
|
10450
10513
|
|
|
10451
10514
|
const logger$6 = IssueReporter$1.loggerFor('simple-phone');
|
|
@@ -10830,7 +10893,7 @@ class Phone extends Emitter {
|
|
|
10830
10893
|
|
|
10831
10894
|
checkSfu() {
|
|
10832
10895
|
if (!this.hasSfu()) {
|
|
10833
|
-
throw new
|
|
10896
|
+
throw new SFUNotAvailableError();
|
|
10834
10897
|
}
|
|
10835
10898
|
}
|
|
10836
10899
|
|
|
@@ -13604,6 +13667,7 @@ const Wazo = {
|
|
|
13604
13667
|
InvalidSubscription,
|
|
13605
13668
|
InvalidAuthorization,
|
|
13606
13669
|
CanceledCallError,
|
|
13670
|
+
SFUNotAvailableError,
|
|
13607
13671
|
};
|
|
13608
13672
|
|
|
13609
13673
|
if (window) {
|
|
@@ -1246,7 +1246,7 @@ class Contact {
|
|
|
1246
1246
|
this[key] = old[key] || this[key];
|
|
1247
1247
|
});
|
|
1248
1248
|
|
|
1249
|
-
if (old.lineState
|
|
1249
|
+
if (old.lineState) {
|
|
1250
1250
|
this.lineState = old.lineState;
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
@@ -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.
|
|
@@ -8728,6 +8760,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
|
|
|
8728
8760
|
const ON_CAMERA_RESUMED = 'onCameraResumed';
|
|
8729
8761
|
const ON_CALL_CANCELED = 'onCallCanceled';
|
|
8730
8762
|
const ON_CALL_FAILED = 'onCallFailed';
|
|
8763
|
+
const ON_CALL_REJECTED = 'onCallRejected';
|
|
8731
8764
|
const ON_CALL_ENDED = 'onCallEnded';
|
|
8732
8765
|
const ON_CALL_ENDING = 'onCallEnding';
|
|
8733
8766
|
const ON_MESSAGE = 'onMessage';
|
|
@@ -8772,6 +8805,7 @@ const events = [
|
|
|
8772
8805
|
ON_CAMERA_DISABLED,
|
|
8773
8806
|
ON_CALL_FAILED,
|
|
8774
8807
|
ON_CALL_ENDED,
|
|
8808
|
+
ON_CALL_REJECTED,
|
|
8775
8809
|
ON_MESSAGE,
|
|
8776
8810
|
ON_REINVITE,
|
|
8777
8811
|
ON_TRACK,
|
|
@@ -9128,6 +9162,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9128
9162
|
|
|
9129
9163
|
// Should be called before `_onCallTerminated` or the callCount will not decrement...
|
|
9130
9164
|
const callSession = this._createCallSession(sipSession);
|
|
9165
|
+
callSession.endTime = new Date();
|
|
9131
9166
|
const wasCurrentSession = this._onCallTerminated(sipSession);
|
|
9132
9167
|
|
|
9133
9168
|
return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
|
|
@@ -9323,6 +9358,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9323
9358
|
this.removeIncomingSessions(sipSessionId);
|
|
9324
9359
|
}
|
|
9325
9360
|
|
|
9361
|
+
callSession.answerTime = new Date();
|
|
9326
9362
|
this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
|
|
9327
9363
|
|
|
9328
9364
|
return callSession;
|
|
@@ -9380,6 +9416,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9380
9416
|
_onCallTerminated(sipSession ) {
|
|
9381
9417
|
logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
|
|
9382
9418
|
|
|
9419
|
+
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9383
9420
|
const callSession = this._createCallSession(sipSession);
|
|
9384
9421
|
const isCurrentSession = this.isCurrentCallSipSession(callSession);
|
|
9385
9422
|
const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
|
|
@@ -9397,7 +9434,6 @@ class WebRTCPhone extends Emitter {
|
|
|
9397
9434
|
}, 5);
|
|
9398
9435
|
}
|
|
9399
9436
|
|
|
9400
|
-
const sipSessionId = this.getSipSessionId(sipSession);
|
|
9401
9437
|
if (sipSessionId) {
|
|
9402
9438
|
this.removeIncomingSessions(sipSessionId);
|
|
9403
9439
|
}
|
|
@@ -9538,6 +9574,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9538
9574
|
}
|
|
9539
9575
|
|
|
9540
9576
|
this.shouldSendReinvite = false;
|
|
9577
|
+
callSession.answerTime = new Date();
|
|
9541
9578
|
this.acceptedSessions[callSession.getId()] = true;
|
|
9542
9579
|
|
|
9543
9580
|
this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
|
|
@@ -9847,6 +9884,7 @@ class WebRTCPhone extends Emitter {
|
|
|
9847
9884
|
return Promise.resolve(null);
|
|
9848
9885
|
}
|
|
9849
9886
|
const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
|
|
9887
|
+
callSession.creationTime = new Date();
|
|
9850
9888
|
|
|
9851
9889
|
this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
|
|
9852
9890
|
|
|
@@ -10042,8 +10080,12 @@ class WebRTCPhone extends Emitter {
|
|
|
10042
10080
|
}
|
|
10043
10081
|
|
|
10044
10082
|
const sessionId = this.incomingSessions[0];
|
|
10083
|
+
const sipSession = this.client.getSipSession(sessionId);
|
|
10084
|
+
if (!sipSession) {
|
|
10085
|
+
return null;
|
|
10086
|
+
}
|
|
10045
10087
|
|
|
10046
|
-
return this._createCallSession(
|
|
10088
|
+
return this._createCallSession(sipSession);
|
|
10047
10089
|
}
|
|
10048
10090
|
|
|
10049
10091
|
sendMessage(sipSession = null, body , contentType = 'text/plain') {
|
|
@@ -10121,6 +10163,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10121
10163
|
callSession);
|
|
10122
10164
|
}
|
|
10123
10165
|
|
|
10166
|
+
callSession.creationTime = new Date();
|
|
10124
10167
|
this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
|
|
10125
10168
|
});
|
|
10126
10169
|
|
|
@@ -10160,6 +10203,13 @@ class WebRTCPhone extends Emitter {
|
|
|
10160
10203
|
this.eventEmitter.emit(ON_CALL_ERROR, e);
|
|
10161
10204
|
});
|
|
10162
10205
|
|
|
10206
|
+
this.client.on(this.client.REJECTED, session => {
|
|
10207
|
+
logger$7.info('WebRTC call rejected', session.id);
|
|
10208
|
+
const callSession = this._createCallSession(session);
|
|
10209
|
+
callSession.endTime = new Date();
|
|
10210
|
+
this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
|
|
10211
|
+
});
|
|
10212
|
+
|
|
10163
10213
|
this.client.on(this.client.UNREGISTERED, () => {
|
|
10164
10214
|
logger$7.info('WebRTC unregistered');
|
|
10165
10215
|
this.eventEmitter.emit(ON_UNREGISTERED);
|
|
@@ -10372,6 +10422,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10372
10422
|
const number = identity ? identity.uri._normal.user : null;
|
|
10373
10423
|
const { state } = sipSession || {};
|
|
10374
10424
|
const sessionId = this.getSipSessionId(sipSession);
|
|
10425
|
+
fromSession = fromSession || this.callSessions[sessionId];
|
|
10375
10426
|
|
|
10376
10427
|
const callSession = new CallSession({
|
|
10377
10428
|
callId: fromSession && fromSession.callId,
|
|
@@ -10379,6 +10430,8 @@ class WebRTCPhone extends Emitter {
|
|
|
10379
10430
|
sipStatus: state,
|
|
10380
10431
|
displayName: identity ? identity.displayName || number : number,
|
|
10381
10432
|
startTime: fromSession ? fromSession.startTime : new Date(),
|
|
10433
|
+
creationTime: fromSession ? fromSession.creationTime : null,
|
|
10434
|
+
endTime: fromSession ? fromSession.endTime : null,
|
|
10382
10435
|
answered: state === sessionState.SessionState.Established,
|
|
10383
10436
|
paused: this.client.isCallHeld(sipSession),
|
|
10384
10437
|
isCaller: 'incoming' in extra ? !extra.incoming : false,
|
|
@@ -10389,6 +10442,7 @@ class WebRTCPhone extends Emitter {
|
|
|
10389
10442
|
videoMuted: fromSession ? fromSession.isVideoMuted() : false,
|
|
10390
10443
|
recording: fromSession ? fromSession.isRecording() : false,
|
|
10391
10444
|
recordingPaused: false, // @TODO
|
|
10445
|
+
sipSession,
|
|
10392
10446
|
...extra,
|
|
10393
10447
|
});
|
|
10394
10448
|
|
|
@@ -10417,6 +10471,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10417
10471
|
ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
|
|
10418
10472
|
ON_CALL_CANCELED: ON_CALL_CANCELED,
|
|
10419
10473
|
ON_CALL_FAILED: ON_CALL_FAILED,
|
|
10474
|
+
ON_CALL_REJECTED: ON_CALL_REJECTED,
|
|
10420
10475
|
ON_CALL_ENDED: ON_CALL_ENDED,
|
|
10421
10476
|
ON_CALL_ENDING: ON_CALL_ENDING,
|
|
10422
10477
|
ON_MESSAGE: ON_MESSAGE,
|
|
@@ -10446,6 +10501,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
|
|
|
10446
10501
|
'default': WebRTCPhone
|
|
10447
10502
|
});
|
|
10448
10503
|
|
|
10504
|
+
/* */
|
|
10505
|
+
class SFUNotAvailableError extends Error {
|
|
10506
|
+
constructor(message = 'Sorry your user is not configured to support video conference') {
|
|
10507
|
+
super(message);
|
|
10508
|
+
this.name = 'SFUNotAvailableError';
|
|
10509
|
+
}
|
|
10510
|
+
}
|
|
10511
|
+
|
|
10449
10512
|
//
|
|
10450
10513
|
|
|
10451
10514
|
const logger$6 = IssueReporter$1.loggerFor('simple-phone');
|
|
@@ -10830,7 +10893,7 @@ class Phone extends Emitter {
|
|
|
10830
10893
|
|
|
10831
10894
|
checkSfu() {
|
|
10832
10895
|
if (!this.hasSfu()) {
|
|
10833
|
-
throw new
|
|
10896
|
+
throw new SFUNotAvailableError();
|
|
10834
10897
|
}
|
|
10835
10898
|
}
|
|
10836
10899
|
|
|
@@ -13685,6 +13748,7 @@ const Wazo = {
|
|
|
13685
13748
|
InvalidSubscription,
|
|
13686
13749
|
InvalidAuthorization,
|
|
13687
13750
|
CanceledCallError,
|
|
13751
|
+
SFUNotAvailableError,
|
|
13688
13752
|
};
|
|
13689
13753
|
|
|
13690
13754
|
if (window) {
|