@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
@@ -3263,8 +3263,10 @@ var updateFrom = (instance , from ) => {
3263
3263
 
3264
3264
 
3265
3265
 
3266
+
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3270
3272
 
@@ -3281,6 +3283,7 @@ var updateFrom = (instance , from ) => {
3281
3283
 
3282
3284
 
3283
3285
 
3286
+
3284
3287
 
3285
3288
 
3286
3289
  class CallSession {
@@ -3300,8 +3303,12 @@ class CallSession {
3300
3303
 
3301
3304
 
3302
3305
 
3306
+
3307
+
3303
3308
 
3304
3309
 
3310
+
3311
+
3305
3312
 
3306
3313
 
3307
3314
 
@@ -3339,6 +3346,8 @@ class CallSession {
3339
3346
 
3340
3347
 
3341
3348
 
3349
+
3350
+
3342
3351
 
3343
3352
  constructor({
3344
3353
  answered,
@@ -3352,6 +3361,8 @@ class CallSession {
3352
3361
  paused,
3353
3362
  ringing,
3354
3363
  startTime,
3364
+ creationTime,
3365
+ endTime,
3355
3366
  cameraEnabled,
3356
3367
  dialedExtension,
3357
3368
  sipCallId,
@@ -3364,12 +3375,15 @@ class CallSession {
3364
3375
  recording,
3365
3376
  recordingPaused,
3366
3377
  videoRemotelyDowngraded,
3378
+ sipSession,
3367
3379
  } ) {
3368
3380
  this.callId = callId;
3369
3381
  this.sipCallId = sipCallId;
3370
3382
  this.displayName = displayName;
3371
3383
  this.number = number;
3384
+ this.creationTime = creationTime;
3372
3385
  this.startTime = startTime;
3386
+ this.endTime = endTime;
3373
3387
  this.isCaller = isCaller;
3374
3388
  this.answered = answered;
3375
3389
  this.answeredBySystem = answeredBySystem;
@@ -3388,6 +3402,7 @@ class CallSession {
3388
3402
  this.recording = recording || false;
3389
3403
  this.recordingPaused = recordingPaused || false;
3390
3404
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3405
+ this.sipSession = sipSession;
3391
3406
 
3392
3407
  // Useful to compare instead of instanceof with minified code
3393
3408
  this.type = 'CallSession';
@@ -8733,6 +8748,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8733
8748
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8734
8749
  const ON_CALL_CANCELED = 'onCallCanceled';
8735
8750
  const ON_CALL_FAILED = 'onCallFailed';
8751
+ const ON_CALL_REJECTED = 'onCallRejected';
8736
8752
  const ON_CALL_ENDED = 'onCallEnded';
8737
8753
  const ON_CALL_ENDING = 'onCallEnding';
8738
8754
  const ON_MESSAGE = 'onMessage';
@@ -8777,6 +8793,7 @@ const events = [
8777
8793
  ON_CAMERA_DISABLED,
8778
8794
  ON_CALL_FAILED,
8779
8795
  ON_CALL_ENDED,
8796
+ ON_CALL_REJECTED,
8780
8797
  ON_MESSAGE,
8781
8798
  ON_REINVITE,
8782
8799
  ON_TRACK,
@@ -9133,6 +9150,7 @@ class WebRTCPhone extends Emitter {
9133
9150
 
9134
9151
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9135
9152
  const callSession = this._createCallSession(sipSession);
9153
+ callSession.endTime = new Date();
9136
9154
  const wasCurrentSession = this._onCallTerminated(sipSession);
9137
9155
 
9138
9156
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9852,6 +9870,7 @@ class WebRTCPhone extends Emitter {
9852
9870
  return Promise.resolve(null);
9853
9871
  }
9854
9872
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9873
+ callSession.creationTime = new Date();
9855
9874
 
9856
9875
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9857
9876
 
@@ -10130,6 +10149,7 @@ class WebRTCPhone extends Emitter {
10130
10149
  callSession);
10131
10150
  }
10132
10151
 
10152
+ callSession.creationTime = new Date();
10133
10153
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10134
10154
  });
10135
10155
 
@@ -10169,6 +10189,13 @@ class WebRTCPhone extends Emitter {
10169
10189
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10170
10190
  });
10171
10191
 
10192
+ this.client.on(this.client.REJECTED, session => {
10193
+ logger$7.info('WebRTC call rejected', session.id);
10194
+ const callSession = this._createCallSession(session);
10195
+ callSession.endTime = new Date();
10196
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10197
+ });
10198
+
10172
10199
  this.client.on(this.client.UNREGISTERED, () => {
10173
10200
  logger$7.info('WebRTC unregistered');
10174
10201
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10381,6 +10408,7 @@ class WebRTCPhone extends Emitter {
10381
10408
  const number = identity ? identity.uri._normal.user : null;
10382
10409
  const { state } = sipSession || {};
10383
10410
  const sessionId = this.getSipSessionId(sipSession);
10411
+ fromSession = fromSession || this.callSessions[sessionId];
10384
10412
 
10385
10413
  const callSession = new CallSession({
10386
10414
  callId: fromSession && fromSession.callId,
@@ -10388,6 +10416,8 @@ class WebRTCPhone extends Emitter {
10388
10416
  sipStatus: state,
10389
10417
  displayName: identity ? identity.displayName || number : number,
10390
10418
  startTime: fromSession ? fromSession.startTime : new Date(),
10419
+ creationTime: fromSession ? fromSession.creationTime : null,
10420
+ endTime: fromSession ? fromSession.endTime : null,
10391
10421
  answered: state === sessionState.SessionState.Established,
10392
10422
  paused: this.client.isCallHeld(sipSession),
10393
10423
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10398,6 +10428,7 @@ class WebRTCPhone extends Emitter {
10398
10428
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10399
10429
  recording: fromSession ? fromSession.isRecording() : false,
10400
10430
  recordingPaused: false, // @TODO
10431
+ sipSession,
10401
10432
  ...extra,
10402
10433
  });
10403
10434
 
@@ -10426,6 +10457,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10426
10457
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10427
10458
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10428
10459
  ON_CALL_FAILED: ON_CALL_FAILED,
10460
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10429
10461
  ON_CALL_ENDED: ON_CALL_ENDED,
10430
10462
  ON_CALL_ENDING: ON_CALL_ENDING,
10431
10463
  ON_MESSAGE: ON_MESSAGE,
@@ -10455,6 +10487,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10455
10487
  'default': WebRTCPhone
10456
10488
  });
10457
10489
 
10490
+ /* */
10491
+ class SFUNotAvailableError extends Error {
10492
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10493
+ super(message);
10494
+ this.name = 'SFUNotAvailableError';
10495
+ }
10496
+ }
10497
+
10458
10498
  //
10459
10499
 
10460
10500
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10839,7 +10879,7 @@ class Phone extends Emitter {
10839
10879
 
10840
10880
  checkSfu() {
10841
10881
  if (!this.hasSfu()) {
10842
- throw new Error('Sorry your user is not configured to support video conference');
10882
+ throw new SFUNotAvailableError();
10843
10883
  }
10844
10884
  }
10845
10885
 
@@ -13613,6 +13653,7 @@ const Wazo = {
13613
13653
  InvalidSubscription,
13614
13654
  InvalidAuthorization,
13615
13655
  CanceledCallError,
13656
+ SFUNotAvailableError,
13616
13657
  };
13617
13658
 
13618
13659
  if (window) {
@@ -3263,8 +3263,10 @@ var updateFrom = (instance , from ) => {
3263
3263
 
3264
3264
 
3265
3265
 
3266
+
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3270
3272
 
@@ -3281,6 +3283,7 @@ var updateFrom = (instance , from ) => {
3281
3283
 
3282
3284
 
3283
3285
 
3286
+
3284
3287
 
3285
3288
 
3286
3289
  class CallSession {
@@ -3300,8 +3303,12 @@ class CallSession {
3300
3303
 
3301
3304
 
3302
3305
 
3306
+
3307
+
3303
3308
 
3304
3309
 
3310
+
3311
+
3305
3312
 
3306
3313
 
3307
3314
 
@@ -3339,6 +3346,8 @@ class CallSession {
3339
3346
 
3340
3347
 
3341
3348
 
3349
+
3350
+
3342
3351
 
3343
3352
  constructor({
3344
3353
  answered,
@@ -3352,6 +3361,8 @@ class CallSession {
3352
3361
  paused,
3353
3362
  ringing,
3354
3363
  startTime,
3364
+ creationTime,
3365
+ endTime,
3355
3366
  cameraEnabled,
3356
3367
  dialedExtension,
3357
3368
  sipCallId,
@@ -3364,12 +3375,15 @@ class CallSession {
3364
3375
  recording,
3365
3376
  recordingPaused,
3366
3377
  videoRemotelyDowngraded,
3378
+ sipSession,
3367
3379
  } ) {
3368
3380
  this.callId = callId;
3369
3381
  this.sipCallId = sipCallId;
3370
3382
  this.displayName = displayName;
3371
3383
  this.number = number;
3384
+ this.creationTime = creationTime;
3372
3385
  this.startTime = startTime;
3386
+ this.endTime = endTime;
3373
3387
  this.isCaller = isCaller;
3374
3388
  this.answered = answered;
3375
3389
  this.answeredBySystem = answeredBySystem;
@@ -3388,6 +3402,7 @@ class CallSession {
3388
3402
  this.recording = recording || false;
3389
3403
  this.recordingPaused = recordingPaused || false;
3390
3404
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3405
+ this.sipSession = sipSession;
3391
3406
 
3392
3407
  // Useful to compare instead of instanceof with minified code
3393
3408
  this.type = 'CallSession';
@@ -8733,6 +8748,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8733
8748
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8734
8749
  const ON_CALL_CANCELED = 'onCallCanceled';
8735
8750
  const ON_CALL_FAILED = 'onCallFailed';
8751
+ const ON_CALL_REJECTED = 'onCallRejected';
8736
8752
  const ON_CALL_ENDED = 'onCallEnded';
8737
8753
  const ON_CALL_ENDING = 'onCallEnding';
8738
8754
  const ON_MESSAGE = 'onMessage';
@@ -8777,6 +8793,7 @@ const events = [
8777
8793
  ON_CAMERA_DISABLED,
8778
8794
  ON_CALL_FAILED,
8779
8795
  ON_CALL_ENDED,
8796
+ ON_CALL_REJECTED,
8780
8797
  ON_MESSAGE,
8781
8798
  ON_REINVITE,
8782
8799
  ON_TRACK,
@@ -9133,6 +9150,7 @@ class WebRTCPhone extends Emitter {
9133
9150
 
9134
9151
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9135
9152
  const callSession = this._createCallSession(sipSession);
9153
+ callSession.endTime = new Date();
9136
9154
  const wasCurrentSession = this._onCallTerminated(sipSession);
9137
9155
 
9138
9156
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9852,6 +9870,7 @@ class WebRTCPhone extends Emitter {
9852
9870
  return Promise.resolve(null);
9853
9871
  }
9854
9872
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9873
+ callSession.creationTime = new Date();
9855
9874
 
9856
9875
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9857
9876
 
@@ -10130,6 +10149,7 @@ class WebRTCPhone extends Emitter {
10130
10149
  callSession);
10131
10150
  }
10132
10151
 
10152
+ callSession.creationTime = new Date();
10133
10153
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10134
10154
  });
10135
10155
 
@@ -10169,6 +10189,13 @@ class WebRTCPhone extends Emitter {
10169
10189
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10170
10190
  });
10171
10191
 
10192
+ this.client.on(this.client.REJECTED, session => {
10193
+ logger$7.info('WebRTC call rejected', session.id);
10194
+ const callSession = this._createCallSession(session);
10195
+ callSession.endTime = new Date();
10196
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10197
+ });
10198
+
10172
10199
  this.client.on(this.client.UNREGISTERED, () => {
10173
10200
  logger$7.info('WebRTC unregistered');
10174
10201
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10381,6 +10408,7 @@ class WebRTCPhone extends Emitter {
10381
10408
  const number = identity ? identity.uri._normal.user : null;
10382
10409
  const { state } = sipSession || {};
10383
10410
  const sessionId = this.getSipSessionId(sipSession);
10411
+ fromSession = fromSession || this.callSessions[sessionId];
10384
10412
 
10385
10413
  const callSession = new CallSession({
10386
10414
  callId: fromSession && fromSession.callId,
@@ -10388,6 +10416,8 @@ class WebRTCPhone extends Emitter {
10388
10416
  sipStatus: state,
10389
10417
  displayName: identity ? identity.displayName || number : number,
10390
10418
  startTime: fromSession ? fromSession.startTime : new Date(),
10419
+ creationTime: fromSession ? fromSession.creationTime : null,
10420
+ endTime: fromSession ? fromSession.endTime : null,
10391
10421
  answered: state === sessionState.SessionState.Established,
10392
10422
  paused: this.client.isCallHeld(sipSession),
10393
10423
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10398,6 +10428,7 @@ class WebRTCPhone extends Emitter {
10398
10428
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10399
10429
  recording: fromSession ? fromSession.isRecording() : false,
10400
10430
  recordingPaused: false, // @TODO
10431
+ sipSession,
10401
10432
  ...extra,
10402
10433
  });
10403
10434
 
@@ -10426,6 +10457,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10426
10457
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10427
10458
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10428
10459
  ON_CALL_FAILED: ON_CALL_FAILED,
10460
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10429
10461
  ON_CALL_ENDED: ON_CALL_ENDED,
10430
10462
  ON_CALL_ENDING: ON_CALL_ENDING,
10431
10463
  ON_MESSAGE: ON_MESSAGE,
@@ -10455,6 +10487,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10455
10487
  'default': WebRTCPhone
10456
10488
  });
10457
10489
 
10490
+ /* */
10491
+ class SFUNotAvailableError extends Error {
10492
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10493
+ super(message);
10494
+ this.name = 'SFUNotAvailableError';
10495
+ }
10496
+ }
10497
+
10458
10498
  //
10459
10499
 
10460
10500
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10839,7 +10879,7 @@ class Phone extends Emitter {
10839
10879
 
10840
10880
  checkSfu() {
10841
10881
  if (!this.hasSfu()) {
10842
- throw new Error('Sorry your user is not configured to support video conference');
10882
+ throw new SFUNotAvailableError();
10843
10883
  }
10844
10884
  }
10845
10885
 
@@ -13694,6 +13734,7 @@ const Wazo = {
13694
13734
  InvalidSubscription,
13695
13735
  InvalidAuthorization,
13696
13736
  CanceledCallError,
13737
+ SFUNotAvailableError,
13697
13738
  };
13698
13739
 
13699
13740
  if (window) {
@@ -3263,8 +3263,10 @@ var updateFrom = (instance , from ) => {
3263
3263
 
3264
3264
 
3265
3265
 
3266
+
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3270
3272
 
@@ -3281,6 +3283,7 @@ var updateFrom = (instance , from ) => {
3281
3283
 
3282
3284
 
3283
3285
 
3286
+
3284
3287
 
3285
3288
 
3286
3289
  class CallSession {
@@ -3300,8 +3303,12 @@ class CallSession {
3300
3303
 
3301
3304
 
3302
3305
 
3306
+
3307
+
3303
3308
 
3304
3309
 
3310
+
3311
+
3305
3312
 
3306
3313
 
3307
3314
 
@@ -3339,6 +3346,8 @@ class CallSession {
3339
3346
 
3340
3347
 
3341
3348
 
3349
+
3350
+
3342
3351
 
3343
3352
  constructor({
3344
3353
  answered,
@@ -3352,6 +3361,8 @@ class CallSession {
3352
3361
  paused,
3353
3362
  ringing,
3354
3363
  startTime,
3364
+ creationTime,
3365
+ endTime,
3355
3366
  cameraEnabled,
3356
3367
  dialedExtension,
3357
3368
  sipCallId,
@@ -3364,12 +3375,15 @@ class CallSession {
3364
3375
  recording,
3365
3376
  recordingPaused,
3366
3377
  videoRemotelyDowngraded,
3378
+ sipSession,
3367
3379
  } ) {
3368
3380
  this.callId = callId;
3369
3381
  this.sipCallId = sipCallId;
3370
3382
  this.displayName = displayName;
3371
3383
  this.number = number;
3384
+ this.creationTime = creationTime;
3372
3385
  this.startTime = startTime;
3386
+ this.endTime = endTime;
3373
3387
  this.isCaller = isCaller;
3374
3388
  this.answered = answered;
3375
3389
  this.answeredBySystem = answeredBySystem;
@@ -3388,6 +3402,7 @@ class CallSession {
3388
3402
  this.recording = recording || false;
3389
3403
  this.recordingPaused = recordingPaused || false;
3390
3404
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3405
+ this.sipSession = sipSession;
3391
3406
 
3392
3407
  // Useful to compare instead of instanceof with minified code
3393
3408
  this.type = 'CallSession';
@@ -8733,6 +8748,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8733
8748
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8734
8749
  const ON_CALL_CANCELED = 'onCallCanceled';
8735
8750
  const ON_CALL_FAILED = 'onCallFailed';
8751
+ const ON_CALL_REJECTED = 'onCallRejected';
8736
8752
  const ON_CALL_ENDED = 'onCallEnded';
8737
8753
  const ON_CALL_ENDING = 'onCallEnding';
8738
8754
  const ON_MESSAGE = 'onMessage';
@@ -8777,6 +8793,7 @@ const events = [
8777
8793
  ON_CAMERA_DISABLED,
8778
8794
  ON_CALL_FAILED,
8779
8795
  ON_CALL_ENDED,
8796
+ ON_CALL_REJECTED,
8780
8797
  ON_MESSAGE,
8781
8798
  ON_REINVITE,
8782
8799
  ON_TRACK,
@@ -9133,6 +9150,7 @@ class WebRTCPhone extends Emitter {
9133
9150
 
9134
9151
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9135
9152
  const callSession = this._createCallSession(sipSession);
9153
+ callSession.endTime = new Date();
9136
9154
  const wasCurrentSession = this._onCallTerminated(sipSession);
9137
9155
 
9138
9156
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9852,6 +9870,7 @@ class WebRTCPhone extends Emitter {
9852
9870
  return Promise.resolve(null);
9853
9871
  }
9854
9872
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9873
+ callSession.creationTime = new Date();
9855
9874
 
9856
9875
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9857
9876
 
@@ -10130,6 +10149,7 @@ class WebRTCPhone extends Emitter {
10130
10149
  callSession);
10131
10150
  }
10132
10151
 
10152
+ callSession.creationTime = new Date();
10133
10153
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10134
10154
  });
10135
10155
 
@@ -10169,6 +10189,13 @@ class WebRTCPhone extends Emitter {
10169
10189
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10170
10190
  });
10171
10191
 
10192
+ this.client.on(this.client.REJECTED, session => {
10193
+ logger$7.info('WebRTC call rejected', session.id);
10194
+ const callSession = this._createCallSession(session);
10195
+ callSession.endTime = new Date();
10196
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10197
+ });
10198
+
10172
10199
  this.client.on(this.client.UNREGISTERED, () => {
10173
10200
  logger$7.info('WebRTC unregistered');
10174
10201
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10381,6 +10408,7 @@ class WebRTCPhone extends Emitter {
10381
10408
  const number = identity ? identity.uri._normal.user : null;
10382
10409
  const { state } = sipSession || {};
10383
10410
  const sessionId = this.getSipSessionId(sipSession);
10411
+ fromSession = fromSession || this.callSessions[sessionId];
10384
10412
 
10385
10413
  const callSession = new CallSession({
10386
10414
  callId: fromSession && fromSession.callId,
@@ -10388,6 +10416,8 @@ class WebRTCPhone extends Emitter {
10388
10416
  sipStatus: state,
10389
10417
  displayName: identity ? identity.displayName || number : number,
10390
10418
  startTime: fromSession ? fromSession.startTime : new Date(),
10419
+ creationTime: fromSession ? fromSession.creationTime : null,
10420
+ endTime: fromSession ? fromSession.endTime : null,
10391
10421
  answered: state === sessionState.SessionState.Established,
10392
10422
  paused: this.client.isCallHeld(sipSession),
10393
10423
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10398,6 +10428,7 @@ class WebRTCPhone extends Emitter {
10398
10428
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10399
10429
  recording: fromSession ? fromSession.isRecording() : false,
10400
10430
  recordingPaused: false, // @TODO
10431
+ sipSession,
10401
10432
  ...extra,
10402
10433
  });
10403
10434
 
@@ -10426,6 +10457,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10426
10457
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10427
10458
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10428
10459
  ON_CALL_FAILED: ON_CALL_FAILED,
10460
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10429
10461
  ON_CALL_ENDED: ON_CALL_ENDED,
10430
10462
  ON_CALL_ENDING: ON_CALL_ENDING,
10431
10463
  ON_MESSAGE: ON_MESSAGE,
@@ -10455,6 +10487,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10455
10487
  'default': WebRTCPhone
10456
10488
  });
10457
10489
 
10490
+ /* */
10491
+ class SFUNotAvailableError extends Error {
10492
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10493
+ super(message);
10494
+ this.name = 'SFUNotAvailableError';
10495
+ }
10496
+ }
10497
+
10458
10498
  //
10459
10499
 
10460
10500
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10839,7 +10879,7 @@ class Phone extends Emitter {
10839
10879
 
10840
10880
  checkSfu() {
10841
10881
  if (!this.hasSfu()) {
10842
- throw new Error('Sorry your user is not configured to support video conference');
10882
+ throw new SFUNotAvailableError();
10843
10883
  }
10844
10884
  }
10845
10885
 
@@ -13752,6 +13792,7 @@ const Wazo = {
13752
13792
  InvalidSubscription,
13753
13793
  InvalidAuthorization,
13754
13794
  CanceledCallError,
13795
+ SFUNotAvailableError,
13755
13796
  };
13756
13797
 
13757
13798
  if (window) {