@wazo/sdk 0.37.27 → 0.37.28

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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/domain/CallSession.js +15 -0
  4. package/esm/domain/Phone/CTIPhone.js +15 -0
  5. package/esm/domain/Phone/WebRTCPhone.js +32 -1
  6. package/esm/domain/SFUNotAvailableError.js +9 -0
  7. package/esm/domain/__tests__/CallSession.test.js +15 -0
  8. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
  9. package/esm/domain/__tests__/Room.test.js +15 -0
  10. package/esm/index.js +43 -1
  11. package/esm/simple/Auth.js +42 -1
  12. package/esm/simple/Configuration.js +42 -1
  13. package/esm/simple/Phone.js +42 -1
  14. package/esm/simple/index.js +42 -1
  15. package/esm/simple/room/LocalParticipant.js +42 -1
  16. package/esm/simple/room/Participant.js +42 -1
  17. package/esm/simple/room/RemoteParticipant.js +42 -1
  18. package/esm/simple/room/Room.js +42 -1
  19. package/esm/simple/room/SipRoom.js +42 -1
  20. package/esm/simple/room/Stream.js +42 -1
  21. package/esm/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  22. package/esm/simple/utils.js +42 -1
  23. package/lib/domain/CallSession.js +15 -0
  24. package/lib/domain/Phone/CTIPhone.js +15 -0
  25. package/lib/domain/Phone/WebRTCPhone.js +32 -0
  26. package/lib/domain/SFUNotAvailableError.js +11 -0
  27. package/lib/domain/__tests__/CallSession.test.js +15 -0
  28. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
  29. package/lib/domain/__tests__/Room.test.js +15 -0
  30. package/lib/index.js +43 -1
  31. package/lib/simple/Auth.js +42 -1
  32. package/lib/simple/Configuration.js +42 -1
  33. package/lib/simple/Phone.js +42 -1
  34. package/lib/simple/index.js +42 -1
  35. package/lib/simple/room/LocalParticipant.js +42 -1
  36. package/lib/simple/room/Participant.js +42 -1
  37. package/lib/simple/room/RemoteParticipant.js +42 -1
  38. package/lib/simple/room/Room.js +42 -1
  39. package/lib/simple/room/SipRoom.js +42 -1
  40. package/lib/simple/room/Stream.js +42 -1
  41. package/lib/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  42. package/lib/simple/utils.js +42 -1
  43. package/package.json +1 -1
  44. package/src/domain/CallSession.js +16 -0
  45. package/src/domain/Phone/WebRTCPhone.js +16 -0
  46. package/src/domain/SFUNotAvailableError.js +7 -0
  47. package/src/index.js +2 -0
  48. package/src/simple/Phone.js +2 -1
  49. package/src/simple/index.js +2 -0
package/esm/index.js CHANGED
@@ -3254,8 +3254,10 @@ var updateFrom = (instance , from ) => {
3254
3254
 
3255
3255
 
3256
3256
 
3257
+
3257
3258
 
3258
3259
 
3260
+
3259
3261
 
3260
3262
 
3261
3263
 
@@ -3272,6 +3274,7 @@ var updateFrom = (instance , from ) => {
3272
3274
 
3273
3275
 
3274
3276
 
3277
+
3275
3278
 
3276
3279
 
3277
3280
  class CallSession {
@@ -3291,8 +3294,12 @@ class CallSession {
3291
3294
 
3292
3295
 
3293
3296
 
3297
+
3298
+
3294
3299
 
3295
3300
 
3301
+
3302
+
3296
3303
 
3297
3304
 
3298
3305
 
@@ -3330,6 +3337,8 @@ class CallSession {
3330
3337
 
3331
3338
 
3332
3339
 
3340
+
3341
+
3333
3342
 
3334
3343
  constructor({
3335
3344
  answered,
@@ -3343,6 +3352,8 @@ class CallSession {
3343
3352
  paused,
3344
3353
  ringing,
3345
3354
  startTime,
3355
+ creationTime,
3356
+ endTime,
3346
3357
  cameraEnabled,
3347
3358
  dialedExtension,
3348
3359
  sipCallId,
@@ -3355,12 +3366,15 @@ class CallSession {
3355
3366
  recording,
3356
3367
  recordingPaused,
3357
3368
  videoRemotelyDowngraded,
3369
+ sipSession,
3358
3370
  } ) {
3359
3371
  this.callId = callId;
3360
3372
  this.sipCallId = sipCallId;
3361
3373
  this.displayName = displayName;
3362
3374
  this.number = number;
3375
+ this.creationTime = creationTime;
3363
3376
  this.startTime = startTime;
3377
+ this.endTime = endTime;
3364
3378
  this.isCaller = isCaller;
3365
3379
  this.answered = answered;
3366
3380
  this.answeredBySystem = answeredBySystem;
@@ -3379,6 +3393,7 @@ class CallSession {
3379
3393
  this.recording = recording || false;
3380
3394
  this.recordingPaused = recordingPaused || false;
3381
3395
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3396
+ this.sipSession = sipSession;
3382
3397
 
3383
3398
  // Useful to compare instead of instanceof with minified code
3384
3399
  this.type = 'CallSession';
@@ -8781,6 +8796,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8781
8796
  'default': WebSocketClient
8782
8797
  });
8783
8798
 
8799
+ /* */
8800
+ class SFUNotAvailableError extends Error {
8801
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8802
+ super(message);
8803
+ this.name = 'SFUNotAvailableError';
8804
+ }
8805
+ }
8806
+
8784
8807
  var COUNTRIES = {
8785
8808
  BELGIUM: 'BE',
8786
8809
  CANADA: 'CA',
@@ -9178,6 +9201,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9178
9201
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9179
9202
  const ON_CALL_CANCELED = 'onCallCanceled';
9180
9203
  const ON_CALL_FAILED = 'onCallFailed';
9204
+ const ON_CALL_REJECTED = 'onCallRejected';
9181
9205
  const ON_CALL_ENDED = 'onCallEnded';
9182
9206
  const ON_CALL_ENDING = 'onCallEnding';
9183
9207
  const ON_MESSAGE = 'onMessage';
@@ -9222,6 +9246,7 @@ const events = [
9222
9246
  ON_CAMERA_DISABLED,
9223
9247
  ON_CALL_FAILED,
9224
9248
  ON_CALL_ENDED,
9249
+ ON_CALL_REJECTED,
9225
9250
  ON_MESSAGE,
9226
9251
  ON_REINVITE,
9227
9252
  ON_TRACK,
@@ -9578,6 +9603,7 @@ class WebRTCPhone extends Emitter {
9578
9603
 
9579
9604
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9580
9605
  const callSession = this._createCallSession(sipSession);
9606
+ callSession.endTime = new Date();
9581
9607
  const wasCurrentSession = this._onCallTerminated(sipSession);
9582
9608
 
9583
9609
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -10297,6 +10323,7 @@ class WebRTCPhone extends Emitter {
10297
10323
  return Promise.resolve(null);
10298
10324
  }
10299
10325
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10326
+ callSession.creationTime = new Date();
10300
10327
 
10301
10328
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10302
10329
 
@@ -10575,6 +10602,7 @@ class WebRTCPhone extends Emitter {
10575
10602
  callSession);
10576
10603
  }
10577
10604
 
10605
+ callSession.creationTime = new Date();
10578
10606
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10579
10607
  });
10580
10608
 
@@ -10614,6 +10642,13 @@ class WebRTCPhone extends Emitter {
10614
10642
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10615
10643
  });
10616
10644
 
10645
+ this.client.on(this.client.REJECTED, session => {
10646
+ logger$7.info('WebRTC call rejected', session.id);
10647
+ const callSession = this._createCallSession(session);
10648
+ callSession.endTime = new Date();
10649
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10650
+ });
10651
+
10617
10652
  this.client.on(this.client.UNREGISTERED, () => {
10618
10653
  logger$7.info('WebRTC unregistered');
10619
10654
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10826,6 +10861,7 @@ class WebRTCPhone extends Emitter {
10826
10861
  const number = identity ? identity.uri._normal.user : null;
10827
10862
  const { state } = sipSession || {};
10828
10863
  const sessionId = this.getSipSessionId(sipSession);
10864
+ fromSession = fromSession || this.callSessions[sessionId];
10829
10865
 
10830
10866
  const callSession = new CallSession({
10831
10867
  callId: fromSession && fromSession.callId,
@@ -10833,6 +10869,8 @@ class WebRTCPhone extends Emitter {
10833
10869
  sipStatus: state,
10834
10870
  displayName: identity ? identity.displayName || number : number,
10835
10871
  startTime: fromSession ? fromSession.startTime : new Date(),
10872
+ creationTime: fromSession ? fromSession.creationTime : null,
10873
+ endTime: fromSession ? fromSession.endTime : null,
10836
10874
  answered: state === SessionState.Established,
10837
10875
  paused: this.client.isCallHeld(sipSession),
10838
10876
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10843,6 +10881,7 @@ class WebRTCPhone extends Emitter {
10843
10881
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10844
10882
  recording: fromSession ? fromSession.isRecording() : false,
10845
10883
  recordingPaused: false, // @TODO
10884
+ sipSession,
10846
10885
  ...extra,
10847
10886
  });
10848
10887
 
@@ -10871,6 +10910,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10871
10910
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10872
10911
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10873
10912
  ON_CALL_FAILED: ON_CALL_FAILED,
10913
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10874
10914
  ON_CALL_ENDED: ON_CALL_ENDED,
10875
10915
  ON_CALL_ENDING: ON_CALL_ENDING,
10876
10916
  ON_MESSAGE: ON_MESSAGE,
@@ -12319,7 +12359,7 @@ class Phone extends Emitter {
12319
12359
 
12320
12360
  checkSfu() {
12321
12361
  if (!this.hasSfu()) {
12322
- throw new Error('Sorry your user is not configured to support video conference');
12362
+ throw new SFUNotAvailableError();
12323
12363
  }
12324
12364
  }
12325
12365
 
@@ -13880,6 +13920,7 @@ const Wazo = {
13880
13920
  InvalidSubscription,
13881
13921
  InvalidAuthorization,
13882
13922
  CanceledCallError,
13923
+ SFUNotAvailableError,
13883
13924
  };
13884
13925
 
13885
13926
  if (window) {
@@ -13922,6 +13963,7 @@ var index = {
13922
13963
  WazoWebSocketClient: WebSocketClient,
13923
13964
  BadResponse,
13924
13965
  ServerError,
13966
+ SFUNotAvailableError,
13925
13967
  Call,
13926
13968
  CallSession,
13927
13969
  CTIPhone,
@@ -3253,8 +3253,10 @@ var updateFrom = (instance , from ) => {
3253
3253
 
3254
3254
 
3255
3255
 
3256
+
3256
3257
 
3257
3258
 
3259
+
3258
3260
 
3259
3261
 
3260
3262
 
@@ -3271,6 +3273,7 @@ var updateFrom = (instance , from ) => {
3271
3273
 
3272
3274
 
3273
3275
 
3276
+
3274
3277
 
3275
3278
 
3276
3279
  class CallSession {
@@ -3290,8 +3293,12 @@ class CallSession {
3290
3293
 
3291
3294
 
3292
3295
 
3296
+
3297
+
3293
3298
 
3294
3299
 
3300
+
3301
+
3295
3302
 
3296
3303
 
3297
3304
 
@@ -3329,6 +3336,8 @@ class CallSession {
3329
3336
 
3330
3337
 
3331
3338
 
3339
+
3340
+
3332
3341
 
3333
3342
  constructor({
3334
3343
  answered,
@@ -3342,6 +3351,8 @@ class CallSession {
3342
3351
  paused,
3343
3352
  ringing,
3344
3353
  startTime,
3354
+ creationTime,
3355
+ endTime,
3345
3356
  cameraEnabled,
3346
3357
  dialedExtension,
3347
3358
  sipCallId,
@@ -3354,12 +3365,15 @@ class CallSession {
3354
3365
  recording,
3355
3366
  recordingPaused,
3356
3367
  videoRemotelyDowngraded,
3368
+ sipSession,
3357
3369
  } ) {
3358
3370
  this.callId = callId;
3359
3371
  this.sipCallId = sipCallId;
3360
3372
  this.displayName = displayName;
3361
3373
  this.number = number;
3374
+ this.creationTime = creationTime;
3362
3375
  this.startTime = startTime;
3376
+ this.endTime = endTime;
3363
3377
  this.isCaller = isCaller;
3364
3378
  this.answered = answered;
3365
3379
  this.answeredBySystem = answeredBySystem;
@@ -3378,6 +3392,7 @@ class CallSession {
3378
3392
  this.recording = recording || false;
3379
3393
  this.recordingPaused = recordingPaused || false;
3380
3394
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3395
+ this.sipSession = sipSession;
3381
3396
 
3382
3397
  // Useful to compare instead of instanceof with minified code
3383
3398
  this.type = 'CallSession';
@@ -8459,6 +8474,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8459
8474
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8460
8475
  const ON_CALL_CANCELED = 'onCallCanceled';
8461
8476
  const ON_CALL_FAILED = 'onCallFailed';
8477
+ const ON_CALL_REJECTED = 'onCallRejected';
8462
8478
  const ON_CALL_ENDED = 'onCallEnded';
8463
8479
  const ON_CALL_ENDING = 'onCallEnding';
8464
8480
  const ON_MESSAGE = 'onMessage';
@@ -8503,6 +8519,7 @@ const events = [
8503
8519
  ON_CAMERA_DISABLED,
8504
8520
  ON_CALL_FAILED,
8505
8521
  ON_CALL_ENDED,
8522
+ ON_CALL_REJECTED,
8506
8523
  ON_MESSAGE,
8507
8524
  ON_REINVITE,
8508
8525
  ON_TRACK,
@@ -8859,6 +8876,7 @@ class WebRTCPhone extends Emitter {
8859
8876
 
8860
8877
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8861
8878
  const callSession = this._createCallSession(sipSession);
8879
+ callSession.endTime = new Date();
8862
8880
  const wasCurrentSession = this._onCallTerminated(sipSession);
8863
8881
 
8864
8882
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9578,6 +9596,7 @@ class WebRTCPhone extends Emitter {
9578
9596
  return Promise.resolve(null);
9579
9597
  }
9580
9598
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9599
+ callSession.creationTime = new Date();
9581
9600
 
9582
9601
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9583
9602
 
@@ -9856,6 +9875,7 @@ class WebRTCPhone extends Emitter {
9856
9875
  callSession);
9857
9876
  }
9858
9877
 
9878
+ callSession.creationTime = new Date();
9859
9879
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9860
9880
  });
9861
9881
 
@@ -9895,6 +9915,13 @@ class WebRTCPhone extends Emitter {
9895
9915
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9896
9916
  });
9897
9917
 
9918
+ this.client.on(this.client.REJECTED, session => {
9919
+ logger$8.info('WebRTC call rejected', session.id);
9920
+ const callSession = this._createCallSession(session);
9921
+ callSession.endTime = new Date();
9922
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9923
+ });
9924
+
9898
9925
  this.client.on(this.client.UNREGISTERED, () => {
9899
9926
  logger$8.info('WebRTC unregistered');
9900
9927
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10107,6 +10134,7 @@ class WebRTCPhone extends Emitter {
10107
10134
  const number = identity ? identity.uri._normal.user : null;
10108
10135
  const { state } = sipSession || {};
10109
10136
  const sessionId = this.getSipSessionId(sipSession);
10137
+ fromSession = fromSession || this.callSessions[sessionId];
10110
10138
 
10111
10139
  const callSession = new CallSession({
10112
10140
  callId: fromSession && fromSession.callId,
@@ -10114,6 +10142,8 @@ class WebRTCPhone extends Emitter {
10114
10142
  sipStatus: state,
10115
10143
  displayName: identity ? identity.displayName || number : number,
10116
10144
  startTime: fromSession ? fromSession.startTime : new Date(),
10145
+ creationTime: fromSession ? fromSession.creationTime : null,
10146
+ endTime: fromSession ? fromSession.endTime : null,
10117
10147
  answered: state === SessionState.Established,
10118
10148
  paused: this.client.isCallHeld(sipSession),
10119
10149
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10124,6 +10154,7 @@ class WebRTCPhone extends Emitter {
10124
10154
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10125
10155
  recording: fromSession ? fromSession.isRecording() : false,
10126
10156
  recordingPaused: false, // @TODO
10157
+ sipSession,
10127
10158
  ...extra,
10128
10159
  });
10129
10160
 
@@ -10152,6 +10183,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10152
10183
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10153
10184
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10154
10185
  ON_CALL_FAILED: ON_CALL_FAILED,
10186
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10155
10187
  ON_CALL_ENDED: ON_CALL_ENDED,
10156
10188
  ON_CALL_ENDING: ON_CALL_ENDING,
10157
10189
  ON_MESSAGE: ON_MESSAGE,
@@ -10181,6 +10213,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10181
10213
  'default': WebRTCPhone
10182
10214
  });
10183
10215
 
10216
+ /* */
10217
+ class SFUNotAvailableError extends Error {
10218
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10219
+ super(message);
10220
+ this.name = 'SFUNotAvailableError';
10221
+ }
10222
+ }
10223
+
10184
10224
  //
10185
10225
 
10186
10226
  const logger$7 = IssueReporter$1.loggerFor('simple-phone');
@@ -10565,7 +10605,7 @@ class Phone extends Emitter {
10565
10605
 
10566
10606
  checkSfu() {
10567
10607
  if (!this.hasSfu()) {
10568
- throw new Error('Sorry your user is not configured to support video conference');
10608
+ throw new SFUNotAvailableError();
10569
10609
  }
10570
10610
  }
10571
10611
 
@@ -13478,6 +13518,7 @@ const Wazo = {
13478
13518
  InvalidSubscription,
13479
13519
  InvalidAuthorization,
13480
13520
  CanceledCallError,
13521
+ SFUNotAvailableError,
13481
13522
  };
13482
13523
 
13483
13524
  if (window) {
@@ -3253,8 +3253,10 @@ var updateFrom = (instance , from ) => {
3253
3253
 
3254
3254
 
3255
3255
 
3256
+
3256
3257
 
3257
3258
 
3259
+
3258
3260
 
3259
3261
 
3260
3262
 
@@ -3271,6 +3273,7 @@ var updateFrom = (instance , from ) => {
3271
3273
 
3272
3274
 
3273
3275
 
3276
+
3274
3277
 
3275
3278
 
3276
3279
  class CallSession {
@@ -3290,8 +3293,12 @@ class CallSession {
3290
3293
 
3291
3294
 
3292
3295
 
3296
+
3297
+
3293
3298
 
3294
3299
 
3300
+
3301
+
3295
3302
 
3296
3303
 
3297
3304
 
@@ -3329,6 +3336,8 @@ class CallSession {
3329
3336
 
3330
3337
 
3331
3338
 
3339
+
3340
+
3332
3341
 
3333
3342
  constructor({
3334
3343
  answered,
@@ -3342,6 +3351,8 @@ class CallSession {
3342
3351
  paused,
3343
3352
  ringing,
3344
3353
  startTime,
3354
+ creationTime,
3355
+ endTime,
3345
3356
  cameraEnabled,
3346
3357
  dialedExtension,
3347
3358
  sipCallId,
@@ -3354,12 +3365,15 @@ class CallSession {
3354
3365
  recording,
3355
3366
  recordingPaused,
3356
3367
  videoRemotelyDowngraded,
3368
+ sipSession,
3357
3369
  } ) {
3358
3370
  this.callId = callId;
3359
3371
  this.sipCallId = sipCallId;
3360
3372
  this.displayName = displayName;
3361
3373
  this.number = number;
3374
+ this.creationTime = creationTime;
3362
3375
  this.startTime = startTime;
3376
+ this.endTime = endTime;
3363
3377
  this.isCaller = isCaller;
3364
3378
  this.answered = answered;
3365
3379
  this.answeredBySystem = answeredBySystem;
@@ -3378,6 +3392,7 @@ class CallSession {
3378
3392
  this.recording = recording || false;
3379
3393
  this.recordingPaused = recordingPaused || false;
3380
3394
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3395
+ this.sipSession = sipSession;
3381
3396
 
3382
3397
  // Useful to compare instead of instanceof with minified code
3383
3398
  this.type = 'CallSession';
@@ -8459,6 +8474,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8459
8474
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8460
8475
  const ON_CALL_CANCELED = 'onCallCanceled';
8461
8476
  const ON_CALL_FAILED = 'onCallFailed';
8477
+ const ON_CALL_REJECTED = 'onCallRejected';
8462
8478
  const ON_CALL_ENDED = 'onCallEnded';
8463
8479
  const ON_CALL_ENDING = 'onCallEnding';
8464
8480
  const ON_MESSAGE = 'onMessage';
@@ -8503,6 +8519,7 @@ const events = [
8503
8519
  ON_CAMERA_DISABLED,
8504
8520
  ON_CALL_FAILED,
8505
8521
  ON_CALL_ENDED,
8522
+ ON_CALL_REJECTED,
8506
8523
  ON_MESSAGE,
8507
8524
  ON_REINVITE,
8508
8525
  ON_TRACK,
@@ -8859,6 +8876,7 @@ class WebRTCPhone extends Emitter {
8859
8876
 
8860
8877
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8861
8878
  const callSession = this._createCallSession(sipSession);
8879
+ callSession.endTime = new Date();
8862
8880
  const wasCurrentSession = this._onCallTerminated(sipSession);
8863
8881
 
8864
8882
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9578,6 +9596,7 @@ class WebRTCPhone extends Emitter {
9578
9596
  return Promise.resolve(null);
9579
9597
  }
9580
9598
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9599
+ callSession.creationTime = new Date();
9581
9600
 
9582
9601
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9583
9602
 
@@ -9856,6 +9875,7 @@ class WebRTCPhone extends Emitter {
9856
9875
  callSession);
9857
9876
  }
9858
9877
 
9878
+ callSession.creationTime = new Date();
9859
9879
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9860
9880
  });
9861
9881
 
@@ -9895,6 +9915,13 @@ class WebRTCPhone extends Emitter {
9895
9915
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9896
9916
  });
9897
9917
 
9918
+ this.client.on(this.client.REJECTED, session => {
9919
+ logger$8.info('WebRTC call rejected', session.id);
9920
+ const callSession = this._createCallSession(session);
9921
+ callSession.endTime = new Date();
9922
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9923
+ });
9924
+
9898
9925
  this.client.on(this.client.UNREGISTERED, () => {
9899
9926
  logger$8.info('WebRTC unregistered');
9900
9927
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10107,6 +10134,7 @@ class WebRTCPhone extends Emitter {
10107
10134
  const number = identity ? identity.uri._normal.user : null;
10108
10135
  const { state } = sipSession || {};
10109
10136
  const sessionId = this.getSipSessionId(sipSession);
10137
+ fromSession = fromSession || this.callSessions[sessionId];
10110
10138
 
10111
10139
  const callSession = new CallSession({
10112
10140
  callId: fromSession && fromSession.callId,
@@ -10114,6 +10142,8 @@ class WebRTCPhone extends Emitter {
10114
10142
  sipStatus: state,
10115
10143
  displayName: identity ? identity.displayName || number : number,
10116
10144
  startTime: fromSession ? fromSession.startTime : new Date(),
10145
+ creationTime: fromSession ? fromSession.creationTime : null,
10146
+ endTime: fromSession ? fromSession.endTime : null,
10117
10147
  answered: state === SessionState.Established,
10118
10148
  paused: this.client.isCallHeld(sipSession),
10119
10149
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10124,6 +10154,7 @@ class WebRTCPhone extends Emitter {
10124
10154
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10125
10155
  recording: fromSession ? fromSession.isRecording() : false,
10126
10156
  recordingPaused: false, // @TODO
10157
+ sipSession,
10127
10158
  ...extra,
10128
10159
  });
10129
10160
 
@@ -10152,6 +10183,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10152
10183
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10153
10184
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10154
10185
  ON_CALL_FAILED: ON_CALL_FAILED,
10186
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10155
10187
  ON_CALL_ENDED: ON_CALL_ENDED,
10156
10188
  ON_CALL_ENDING: ON_CALL_ENDING,
10157
10189
  ON_MESSAGE: ON_MESSAGE,
@@ -10181,6 +10213,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10181
10213
  'default': WebRTCPhone
10182
10214
  });
10183
10215
 
10216
+ /* */
10217
+ class SFUNotAvailableError extends Error {
10218
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10219
+ super(message);
10220
+ this.name = 'SFUNotAvailableError';
10221
+ }
10222
+ }
10223
+
10184
10224
  //
10185
10225
 
10186
10226
  const logger$7 = IssueReporter$1.loggerFor('simple-phone');
@@ -10565,7 +10605,7 @@ class Phone extends Emitter {
10565
10605
 
10566
10606
  checkSfu() {
10567
10607
  if (!this.hasSfu()) {
10568
- throw new Error('Sorry your user is not configured to support video conference');
10608
+ throw new SFUNotAvailableError();
10569
10609
  }
10570
10610
  }
10571
10611
 
@@ -13461,6 +13501,7 @@ const Wazo = {
13461
13501
  InvalidSubscription,
13462
13502
  InvalidAuthorization,
13463
13503
  CanceledCallError,
13504
+ SFUNotAvailableError,
13464
13505
  };
13465
13506
 
13466
13507
  if (window) {