@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
@@ -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';
@@ -8723,6 +8738,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8723
8738
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8724
8739
  const ON_CALL_CANCELED = 'onCallCanceled';
8725
8740
  const ON_CALL_FAILED = 'onCallFailed';
8741
+ const ON_CALL_REJECTED = 'onCallRejected';
8726
8742
  const ON_CALL_ENDED = 'onCallEnded';
8727
8743
  const ON_CALL_ENDING = 'onCallEnding';
8728
8744
  const ON_MESSAGE = 'onMessage';
@@ -8767,6 +8783,7 @@ const events = [
8767
8783
  ON_CAMERA_DISABLED,
8768
8784
  ON_CALL_FAILED,
8769
8785
  ON_CALL_ENDED,
8786
+ ON_CALL_REJECTED,
8770
8787
  ON_MESSAGE,
8771
8788
  ON_REINVITE,
8772
8789
  ON_TRACK,
@@ -9123,6 +9140,7 @@ class WebRTCPhone extends Emitter {
9123
9140
 
9124
9141
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9125
9142
  const callSession = this._createCallSession(sipSession);
9143
+ callSession.endTime = new Date();
9126
9144
  const wasCurrentSession = this._onCallTerminated(sipSession);
9127
9145
 
9128
9146
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9842,6 +9860,7 @@ class WebRTCPhone extends Emitter {
9842
9860
  return Promise.resolve(null);
9843
9861
  }
9844
9862
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9863
+ callSession.creationTime = new Date();
9845
9864
 
9846
9865
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9847
9866
 
@@ -10120,6 +10139,7 @@ class WebRTCPhone extends Emitter {
10120
10139
  callSession);
10121
10140
  }
10122
10141
 
10142
+ callSession.creationTime = new Date();
10123
10143
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10124
10144
  });
10125
10145
 
@@ -10159,6 +10179,13 @@ class WebRTCPhone extends Emitter {
10159
10179
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10160
10180
  });
10161
10181
 
10182
+ this.client.on(this.client.REJECTED, session => {
10183
+ logger$7.info('WebRTC call rejected', session.id);
10184
+ const callSession = this._createCallSession(session);
10185
+ callSession.endTime = new Date();
10186
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10187
+ });
10188
+
10162
10189
  this.client.on(this.client.UNREGISTERED, () => {
10163
10190
  logger$7.info('WebRTC unregistered');
10164
10191
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10371,6 +10398,7 @@ class WebRTCPhone extends Emitter {
10371
10398
  const number = identity ? identity.uri._normal.user : null;
10372
10399
  const { state } = sipSession || {};
10373
10400
  const sessionId = this.getSipSessionId(sipSession);
10401
+ fromSession = fromSession || this.callSessions[sessionId];
10374
10402
 
10375
10403
  const callSession = new CallSession({
10376
10404
  callId: fromSession && fromSession.callId,
@@ -10378,6 +10406,8 @@ class WebRTCPhone extends Emitter {
10378
10406
  sipStatus: state,
10379
10407
  displayName: identity ? identity.displayName || number : number,
10380
10408
  startTime: fromSession ? fromSession.startTime : new Date(),
10409
+ creationTime: fromSession ? fromSession.creationTime : null,
10410
+ endTime: fromSession ? fromSession.endTime : null,
10381
10411
  answered: state === SessionState.Established,
10382
10412
  paused: this.client.isCallHeld(sipSession),
10383
10413
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10388,6 +10418,7 @@ class WebRTCPhone extends Emitter {
10388
10418
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10389
10419
  recording: fromSession ? fromSession.isRecording() : false,
10390
10420
  recordingPaused: false, // @TODO
10421
+ sipSession,
10391
10422
  ...extra,
10392
10423
  });
10393
10424
 
@@ -10416,6 +10447,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10416
10447
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10417
10448
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10418
10449
  ON_CALL_FAILED: ON_CALL_FAILED,
10450
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10419
10451
  ON_CALL_ENDED: ON_CALL_ENDED,
10420
10452
  ON_CALL_ENDING: ON_CALL_ENDING,
10421
10453
  ON_MESSAGE: ON_MESSAGE,
@@ -10445,6 +10477,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10445
10477
  'default': WebRTCPhone
10446
10478
  });
10447
10479
 
10480
+ /* */
10481
+ class SFUNotAvailableError extends Error {
10482
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10483
+ super(message);
10484
+ this.name = 'SFUNotAvailableError';
10485
+ }
10486
+ }
10487
+
10448
10488
  //
10449
10489
 
10450
10490
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10829,7 +10869,7 @@ class Phone extends Emitter {
10829
10869
 
10830
10870
  checkSfu() {
10831
10871
  if (!this.hasSfu()) {
10832
- throw new Error('Sorry your user is not configured to support video conference');
10872
+ throw new SFUNotAvailableError();
10833
10873
  }
10834
10874
  }
10835
10875
 
@@ -13603,6 +13643,7 @@ const Wazo = {
13603
13643
  InvalidSubscription,
13604
13644
  InvalidAuthorization,
13605
13645
  CanceledCallError,
13646
+ SFUNotAvailableError,
13606
13647
  };
13607
13648
 
13608
13649
  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';
@@ -8723,6 +8738,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8723
8738
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8724
8739
  const ON_CALL_CANCELED = 'onCallCanceled';
8725
8740
  const ON_CALL_FAILED = 'onCallFailed';
8741
+ const ON_CALL_REJECTED = 'onCallRejected';
8726
8742
  const ON_CALL_ENDED = 'onCallEnded';
8727
8743
  const ON_CALL_ENDING = 'onCallEnding';
8728
8744
  const ON_MESSAGE = 'onMessage';
@@ -8767,6 +8783,7 @@ const events = [
8767
8783
  ON_CAMERA_DISABLED,
8768
8784
  ON_CALL_FAILED,
8769
8785
  ON_CALL_ENDED,
8786
+ ON_CALL_REJECTED,
8770
8787
  ON_MESSAGE,
8771
8788
  ON_REINVITE,
8772
8789
  ON_TRACK,
@@ -9123,6 +9140,7 @@ class WebRTCPhone extends Emitter {
9123
9140
 
9124
9141
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9125
9142
  const callSession = this._createCallSession(sipSession);
9143
+ callSession.endTime = new Date();
9126
9144
  const wasCurrentSession = this._onCallTerminated(sipSession);
9127
9145
 
9128
9146
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9842,6 +9860,7 @@ class WebRTCPhone extends Emitter {
9842
9860
  return Promise.resolve(null);
9843
9861
  }
9844
9862
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9863
+ callSession.creationTime = new Date();
9845
9864
 
9846
9865
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9847
9866
 
@@ -10120,6 +10139,7 @@ class WebRTCPhone extends Emitter {
10120
10139
  callSession);
10121
10140
  }
10122
10141
 
10142
+ callSession.creationTime = new Date();
10123
10143
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10124
10144
  });
10125
10145
 
@@ -10159,6 +10179,13 @@ class WebRTCPhone extends Emitter {
10159
10179
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10160
10180
  });
10161
10181
 
10182
+ this.client.on(this.client.REJECTED, session => {
10183
+ logger$7.info('WebRTC call rejected', session.id);
10184
+ const callSession = this._createCallSession(session);
10185
+ callSession.endTime = new Date();
10186
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10187
+ });
10188
+
10162
10189
  this.client.on(this.client.UNREGISTERED, () => {
10163
10190
  logger$7.info('WebRTC unregistered');
10164
10191
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10371,6 +10398,7 @@ class WebRTCPhone extends Emitter {
10371
10398
  const number = identity ? identity.uri._normal.user : null;
10372
10399
  const { state } = sipSession || {};
10373
10400
  const sessionId = this.getSipSessionId(sipSession);
10401
+ fromSession = fromSession || this.callSessions[sessionId];
10374
10402
 
10375
10403
  const callSession = new CallSession({
10376
10404
  callId: fromSession && fromSession.callId,
@@ -10378,6 +10406,8 @@ class WebRTCPhone extends Emitter {
10378
10406
  sipStatus: state,
10379
10407
  displayName: identity ? identity.displayName || number : number,
10380
10408
  startTime: fromSession ? fromSession.startTime : new Date(),
10409
+ creationTime: fromSession ? fromSession.creationTime : null,
10410
+ endTime: fromSession ? fromSession.endTime : null,
10381
10411
  answered: state === SessionState.Established,
10382
10412
  paused: this.client.isCallHeld(sipSession),
10383
10413
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10388,6 +10418,7 @@ class WebRTCPhone extends Emitter {
10388
10418
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10389
10419
  recording: fromSession ? fromSession.isRecording() : false,
10390
10420
  recordingPaused: false, // @TODO
10421
+ sipSession,
10391
10422
  ...extra,
10392
10423
  });
10393
10424
 
@@ -10416,6 +10447,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10416
10447
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10417
10448
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10418
10449
  ON_CALL_FAILED: ON_CALL_FAILED,
10450
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10419
10451
  ON_CALL_ENDED: ON_CALL_ENDED,
10420
10452
  ON_CALL_ENDING: ON_CALL_ENDING,
10421
10453
  ON_MESSAGE: ON_MESSAGE,
@@ -10445,6 +10477,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10445
10477
  'default': WebRTCPhone
10446
10478
  });
10447
10479
 
10480
+ /* */
10481
+ class SFUNotAvailableError extends Error {
10482
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10483
+ super(message);
10484
+ this.name = 'SFUNotAvailableError';
10485
+ }
10486
+ }
10487
+
10448
10488
  //
10449
10489
 
10450
10490
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10829,7 +10869,7 @@ class Phone extends Emitter {
10829
10869
 
10830
10870
  checkSfu() {
10831
10871
  if (!this.hasSfu()) {
10832
- throw new Error('Sorry your user is not configured to support video conference');
10872
+ throw new SFUNotAvailableError();
10833
10873
  }
10834
10874
  }
10835
10875
 
@@ -13684,6 +13724,7 @@ const Wazo = {
13684
13724
  InvalidSubscription,
13685
13725
  InvalidAuthorization,
13686
13726
  CanceledCallError,
13727
+ SFUNotAvailableError,
13687
13728
  };
13688
13729
 
13689
13730
  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';
@@ -8723,6 +8738,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8723
8738
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8724
8739
  const ON_CALL_CANCELED = 'onCallCanceled';
8725
8740
  const ON_CALL_FAILED = 'onCallFailed';
8741
+ const ON_CALL_REJECTED = 'onCallRejected';
8726
8742
  const ON_CALL_ENDED = 'onCallEnded';
8727
8743
  const ON_CALL_ENDING = 'onCallEnding';
8728
8744
  const ON_MESSAGE = 'onMessage';
@@ -8767,6 +8783,7 @@ const events = [
8767
8783
  ON_CAMERA_DISABLED,
8768
8784
  ON_CALL_FAILED,
8769
8785
  ON_CALL_ENDED,
8786
+ ON_CALL_REJECTED,
8770
8787
  ON_MESSAGE,
8771
8788
  ON_REINVITE,
8772
8789
  ON_TRACK,
@@ -9123,6 +9140,7 @@ class WebRTCPhone extends Emitter {
9123
9140
 
9124
9141
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9125
9142
  const callSession = this._createCallSession(sipSession);
9143
+ callSession.endTime = new Date();
9126
9144
  const wasCurrentSession = this._onCallTerminated(sipSession);
9127
9145
 
9128
9146
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9842,6 +9860,7 @@ class WebRTCPhone extends Emitter {
9842
9860
  return Promise.resolve(null);
9843
9861
  }
9844
9862
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9863
+ callSession.creationTime = new Date();
9845
9864
 
9846
9865
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9847
9866
 
@@ -10120,6 +10139,7 @@ class WebRTCPhone extends Emitter {
10120
10139
  callSession);
10121
10140
  }
10122
10141
 
10142
+ callSession.creationTime = new Date();
10123
10143
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10124
10144
  });
10125
10145
 
@@ -10159,6 +10179,13 @@ class WebRTCPhone extends Emitter {
10159
10179
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10160
10180
  });
10161
10181
 
10182
+ this.client.on(this.client.REJECTED, session => {
10183
+ logger$7.info('WebRTC call rejected', session.id);
10184
+ const callSession = this._createCallSession(session);
10185
+ callSession.endTime = new Date();
10186
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10187
+ });
10188
+
10162
10189
  this.client.on(this.client.UNREGISTERED, () => {
10163
10190
  logger$7.info('WebRTC unregistered');
10164
10191
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10371,6 +10398,7 @@ class WebRTCPhone extends Emitter {
10371
10398
  const number = identity ? identity.uri._normal.user : null;
10372
10399
  const { state } = sipSession || {};
10373
10400
  const sessionId = this.getSipSessionId(sipSession);
10401
+ fromSession = fromSession || this.callSessions[sessionId];
10374
10402
 
10375
10403
  const callSession = new CallSession({
10376
10404
  callId: fromSession && fromSession.callId,
@@ -10378,6 +10406,8 @@ class WebRTCPhone extends Emitter {
10378
10406
  sipStatus: state,
10379
10407
  displayName: identity ? identity.displayName || number : number,
10380
10408
  startTime: fromSession ? fromSession.startTime : new Date(),
10409
+ creationTime: fromSession ? fromSession.creationTime : null,
10410
+ endTime: fromSession ? fromSession.endTime : null,
10381
10411
  answered: state === SessionState.Established,
10382
10412
  paused: this.client.isCallHeld(sipSession),
10383
10413
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10388,6 +10418,7 @@ class WebRTCPhone extends Emitter {
10388
10418
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10389
10419
  recording: fromSession ? fromSession.isRecording() : false,
10390
10420
  recordingPaused: false, // @TODO
10421
+ sipSession,
10391
10422
  ...extra,
10392
10423
  });
10393
10424
 
@@ -10416,6 +10447,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10416
10447
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10417
10448
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10418
10449
  ON_CALL_FAILED: ON_CALL_FAILED,
10450
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10419
10451
  ON_CALL_ENDED: ON_CALL_ENDED,
10420
10452
  ON_CALL_ENDING: ON_CALL_ENDING,
10421
10453
  ON_MESSAGE: ON_MESSAGE,
@@ -10445,6 +10477,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10445
10477
  'default': WebRTCPhone
10446
10478
  });
10447
10479
 
10480
+ /* */
10481
+ class SFUNotAvailableError extends Error {
10482
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10483
+ super(message);
10484
+ this.name = 'SFUNotAvailableError';
10485
+ }
10486
+ }
10487
+
10448
10488
  //
10449
10489
 
10450
10490
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10829,7 +10869,7 @@ class Phone extends Emitter {
10829
10869
 
10830
10870
  checkSfu() {
10831
10871
  if (!this.hasSfu()) {
10832
- throw new Error('Sorry your user is not configured to support video conference');
10872
+ throw new SFUNotAvailableError();
10833
10873
  }
10834
10874
  }
10835
10875
 
@@ -13742,6 +13782,7 @@ const Wazo = {
13742
13782
  InvalidSubscription,
13743
13783
  InvalidAuthorization,
13744
13784
  CanceledCallError,
13785
+ SFUNotAvailableError,
13745
13786
  };
13746
13787
 
13747
13788
  if (window) {