@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
@@ -3289,8 +3289,10 @@ var updateFrom = (instance , from ) => {
3289
3289
 
3290
3290
 
3291
3291
 
3292
+
3292
3293
 
3293
3294
 
3295
+
3294
3296
 
3295
3297
 
3296
3298
 
@@ -3307,6 +3309,7 @@ var updateFrom = (instance , from ) => {
3307
3309
 
3308
3310
 
3309
3311
 
3312
+
3310
3313
 
3311
3314
 
3312
3315
  class CallSession {
@@ -3326,8 +3329,12 @@ class CallSession {
3326
3329
 
3327
3330
 
3328
3331
 
3332
+
3333
+
3329
3334
 
3330
3335
 
3336
+
3337
+
3331
3338
 
3332
3339
 
3333
3340
 
@@ -3365,6 +3372,8 @@ class CallSession {
3365
3372
 
3366
3373
 
3367
3374
 
3375
+
3376
+
3368
3377
 
3369
3378
  constructor({
3370
3379
  answered,
@@ -3378,6 +3387,8 @@ class CallSession {
3378
3387
  paused,
3379
3388
  ringing,
3380
3389
  startTime,
3390
+ creationTime,
3391
+ endTime,
3381
3392
  cameraEnabled,
3382
3393
  dialedExtension,
3383
3394
  sipCallId,
@@ -3390,12 +3401,15 @@ class CallSession {
3390
3401
  recording,
3391
3402
  recordingPaused,
3392
3403
  videoRemotelyDowngraded,
3404
+ sipSession,
3393
3405
  } ) {
3394
3406
  this.callId = callId;
3395
3407
  this.sipCallId = sipCallId;
3396
3408
  this.displayName = displayName;
3397
3409
  this.number = number;
3410
+ this.creationTime = creationTime;
3398
3411
  this.startTime = startTime;
3412
+ this.endTime = endTime;
3399
3413
  this.isCaller = isCaller;
3400
3414
  this.answered = answered;
3401
3415
  this.answeredBySystem = answeredBySystem;
@@ -3414,6 +3428,7 @@ class CallSession {
3414
3428
  this.recording = recording || false;
3415
3429
  this.recordingPaused = recordingPaused || false;
3416
3430
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3431
+ this.sipSession = sipSession;
3417
3432
 
3418
3433
  // Useful to compare instead of instanceof with minified code
3419
3434
  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
 
@@ -12626,6 +12666,7 @@ const Wazo = {
12626
12666
  InvalidSubscription,
12627
12667
  InvalidAuthorization,
12628
12668
  CanceledCallError,
12669
+ SFUNotAvailableError,
12629
12670
  };
12630
12671
 
12631
12672
  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
 
@@ -12905,6 +12945,7 @@ const Wazo = {
12905
12945
  InvalidSubscription,
12906
12946
  InvalidAuthorization,
12907
12947
  CanceledCallError,
12948
+ SFUNotAvailableError,
12908
12949
  };
12909
12950
 
12910
12951
  if (window) {
@@ -3265,8 +3265,10 @@ var updateFrom = (instance , from ) => {
3265
3265
 
3266
3266
 
3267
3267
 
3268
+
3268
3269
 
3269
3270
 
3271
+
3270
3272
 
3271
3273
 
3272
3274
 
@@ -3283,6 +3285,7 @@ var updateFrom = (instance , from ) => {
3283
3285
 
3284
3286
 
3285
3287
 
3288
+
3286
3289
 
3287
3290
 
3288
3291
  class CallSession {
@@ -3302,8 +3305,12 @@ class CallSession {
3302
3305
 
3303
3306
 
3304
3307
 
3308
+
3309
+
3305
3310
 
3306
3311
 
3312
+
3313
+
3307
3314
 
3308
3315
 
3309
3316
 
@@ -3341,6 +3348,8 @@ class CallSession {
3341
3348
 
3342
3349
 
3343
3350
 
3351
+
3352
+
3344
3353
 
3345
3354
  constructor({
3346
3355
  answered,
@@ -3354,6 +3363,8 @@ class CallSession {
3354
3363
  paused,
3355
3364
  ringing,
3356
3365
  startTime,
3366
+ creationTime,
3367
+ endTime,
3357
3368
  cameraEnabled,
3358
3369
  dialedExtension,
3359
3370
  sipCallId,
@@ -3366,12 +3377,15 @@ class CallSession {
3366
3377
  recording,
3367
3378
  recordingPaused,
3368
3379
  videoRemotelyDowngraded,
3380
+ sipSession,
3369
3381
  } ) {
3370
3382
  this.callId = callId;
3371
3383
  this.sipCallId = sipCallId;
3372
3384
  this.displayName = displayName;
3373
3385
  this.number = number;
3386
+ this.creationTime = creationTime;
3374
3387
  this.startTime = startTime;
3388
+ this.endTime = endTime;
3375
3389
  this.isCaller = isCaller;
3376
3390
  this.answered = answered;
3377
3391
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3404,7 @@ class CallSession {
3390
3404
  this.recording = recording || false;
3391
3405
  this.recordingPaused = recordingPaused || false;
3392
3406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
+ this.sipSession = sipSession;
3393
3408
 
3394
3409
  // Useful to compare instead of instanceof with minified code
3395
3410
  this.type = 'CallSession';
@@ -8735,6 +8750,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8735
8750
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8736
8751
  const ON_CALL_CANCELED = 'onCallCanceled';
8737
8752
  const ON_CALL_FAILED = 'onCallFailed';
8753
+ const ON_CALL_REJECTED = 'onCallRejected';
8738
8754
  const ON_CALL_ENDED = 'onCallEnded';
8739
8755
  const ON_CALL_ENDING = 'onCallEnding';
8740
8756
  const ON_MESSAGE = 'onMessage';
@@ -8779,6 +8795,7 @@ const events = [
8779
8795
  ON_CAMERA_DISABLED,
8780
8796
  ON_CALL_FAILED,
8781
8797
  ON_CALL_ENDED,
8798
+ ON_CALL_REJECTED,
8782
8799
  ON_MESSAGE,
8783
8800
  ON_REINVITE,
8784
8801
  ON_TRACK,
@@ -9135,6 +9152,7 @@ class WebRTCPhone extends Emitter {
9135
9152
 
9136
9153
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9137
9154
  const callSession = this._createCallSession(sipSession);
9155
+ callSession.endTime = new Date();
9138
9156
  const wasCurrentSession = this._onCallTerminated(sipSession);
9139
9157
 
9140
9158
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9854,6 +9872,7 @@ class WebRTCPhone extends Emitter {
9854
9872
  return Promise.resolve(null);
9855
9873
  }
9856
9874
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9875
+ callSession.creationTime = new Date();
9857
9876
 
9858
9877
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9859
9878
 
@@ -10132,6 +10151,7 @@ class WebRTCPhone extends Emitter {
10132
10151
  callSession);
10133
10152
  }
10134
10153
 
10154
+ callSession.creationTime = new Date();
10135
10155
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10136
10156
  });
10137
10157
 
@@ -10171,6 +10191,13 @@ class WebRTCPhone extends Emitter {
10171
10191
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10172
10192
  });
10173
10193
 
10194
+ this.client.on(this.client.REJECTED, session => {
10195
+ logger$7.info('WebRTC call rejected', session.id);
10196
+ const callSession = this._createCallSession(session);
10197
+ callSession.endTime = new Date();
10198
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10199
+ });
10200
+
10174
10201
  this.client.on(this.client.UNREGISTERED, () => {
10175
10202
  logger$7.info('WebRTC unregistered');
10176
10203
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10383,6 +10410,7 @@ class WebRTCPhone extends Emitter {
10383
10410
  const number = identity ? identity.uri._normal.user : null;
10384
10411
  const { state } = sipSession || {};
10385
10412
  const sessionId = this.getSipSessionId(sipSession);
10413
+ fromSession = fromSession || this.callSessions[sessionId];
10386
10414
 
10387
10415
  const callSession = new CallSession({
10388
10416
  callId: fromSession && fromSession.callId,
@@ -10390,6 +10418,8 @@ class WebRTCPhone extends Emitter {
10390
10418
  sipStatus: state,
10391
10419
  displayName: identity ? identity.displayName || number : number,
10392
10420
  startTime: fromSession ? fromSession.startTime : new Date(),
10421
+ creationTime: fromSession ? fromSession.creationTime : null,
10422
+ endTime: fromSession ? fromSession.endTime : null,
10393
10423
  answered: state === sessionState.SessionState.Established,
10394
10424
  paused: this.client.isCallHeld(sipSession),
10395
10425
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10400,6 +10430,7 @@ class WebRTCPhone extends Emitter {
10400
10430
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10401
10431
  recording: fromSession ? fromSession.isRecording() : false,
10402
10432
  recordingPaused: false, // @TODO
10433
+ sipSession,
10403
10434
  ...extra,
10404
10435
  });
10405
10436
 
@@ -10428,6 +10459,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10428
10459
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10429
10460
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10430
10461
  ON_CALL_FAILED: ON_CALL_FAILED,
10462
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10431
10463
  ON_CALL_ENDED: ON_CALL_ENDED,
10432
10464
  ON_CALL_ENDING: ON_CALL_ENDING,
10433
10465
  ON_MESSAGE: ON_MESSAGE,
@@ -10457,6 +10489,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10457
10489
  'default': WebRTCPhone
10458
10490
  });
10459
10491
 
10492
+ /* */
10493
+ class SFUNotAvailableError extends Error {
10494
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10495
+ super(message);
10496
+ this.name = 'SFUNotAvailableError';
10497
+ }
10498
+ }
10499
+
10460
10500
  //
10461
10501
 
10462
10502
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10841,7 +10881,7 @@ class Phone extends Emitter {
10841
10881
 
10842
10882
  checkSfu() {
10843
10883
  if (!this.hasSfu()) {
10844
- throw new Error('Sorry your user is not configured to support video conference');
10884
+ throw new SFUNotAvailableError();
10845
10885
  }
10846
10886
  }
10847
10887
 
@@ -12918,6 +12958,7 @@ const Wazo = {
12918
12958
  InvalidSubscription,
12919
12959
  InvalidAuthorization,
12920
12960
  CanceledCallError,
12961
+ SFUNotAvailableError,
12921
12962
  };
12922
12963
 
12923
12964
  if (window) {