@wazo/sdk 0.37.27 → 0.37.31

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 (63) hide show
  1. package/README.md +3 -2
  2. package/dist/wazo-sdk.js +4 -4
  3. package/esm/__tests__/web-rtc-client.test.js +9 -1
  4. package/esm/checker/Checker.js +9 -1
  5. package/esm/checker/checks/index.js +9 -1
  6. package/esm/checker/checks/webrtc-transport.js +9 -1
  7. package/esm/checker/checks/webrtc.js +9 -1
  8. package/esm/domain/CallSession.js +29 -2
  9. package/esm/domain/Phone/CTIPhone.js +29 -2
  10. package/esm/domain/Phone/WebRTCPhone.js +57 -4
  11. package/esm/domain/SFUNotAvailableError.js +9 -0
  12. package/esm/domain/__tests__/CallSession.test.js +46 -2
  13. package/esm/domain/__tests__/IndirectTransfer.test.js +29 -2
  14. package/esm/domain/__tests__/Room.test.js +29 -2
  15. package/esm/index.js +77 -5
  16. package/esm/simple/Auth.js +76 -5
  17. package/esm/simple/Configuration.js +76 -5
  18. package/esm/simple/Phone.js +76 -5
  19. package/esm/simple/index.js +76 -5
  20. package/esm/simple/room/LocalParticipant.js +76 -5
  21. package/esm/simple/room/Participant.js +76 -5
  22. package/esm/simple/room/RemoteParticipant.js +76 -5
  23. package/esm/simple/room/Room.js +76 -5
  24. package/esm/simple/room/SipRoom.js +76 -5
  25. package/esm/simple/room/Stream.js +76 -5
  26. package/esm/simple/room/__tests__/RemoteParticipant.test.js +76 -5
  27. package/esm/simple/utils.js +76 -5
  28. package/esm/web-rtc-client.js +9 -1
  29. package/lib/__tests__/web-rtc-client.test.js +9 -1
  30. package/lib/checker/Checker.js +9 -1
  31. package/lib/checker/checks/index.js +9 -1
  32. package/lib/checker/checks/webrtc-transport.js +9 -1
  33. package/lib/checker/checks/webrtc.js +9 -1
  34. package/lib/domain/CallSession.js +29 -2
  35. package/lib/domain/Phone/CTIPhone.js +29 -2
  36. package/lib/domain/Phone/WebRTCPhone.js +57 -3
  37. package/lib/domain/SFUNotAvailableError.js +11 -0
  38. package/lib/domain/__tests__/CallSession.test.js +46 -2
  39. package/lib/domain/__tests__/IndirectTransfer.test.js +29 -2
  40. package/lib/domain/__tests__/Room.test.js +29 -2
  41. package/lib/index.js +77 -5
  42. package/lib/simple/Auth.js +76 -5
  43. package/lib/simple/Configuration.js +76 -5
  44. package/lib/simple/Phone.js +76 -5
  45. package/lib/simple/index.js +76 -5
  46. package/lib/simple/room/LocalParticipant.js +76 -5
  47. package/lib/simple/room/Participant.js +76 -5
  48. package/lib/simple/room/RemoteParticipant.js +76 -5
  49. package/lib/simple/room/Room.js +76 -5
  50. package/lib/simple/room/SipRoom.js +76 -5
  51. package/lib/simple/room/Stream.js +76 -5
  52. package/lib/simple/room/__tests__/RemoteParticipant.test.js +76 -5
  53. package/lib/simple/utils.js +76 -5
  54. package/lib/web-rtc-client.js +9 -1
  55. package/package.json +1 -1
  56. package/src/domain/CallSession.js +32 -4
  57. package/src/domain/Phone/WebRTCPhone.js +27 -1
  58. package/src/domain/SFUNotAvailableError.js +7 -0
  59. package/src/domain/__tests__/CallSession.test.js +17 -0
  60. package/src/index.js +2 -0
  61. package/src/simple/Phone.js +2 -1
  62. package/src/simple/index.js +2 -0
  63. package/src/web-rtc-client.js +9 -1
@@ -3284,13 +3284,16 @@ var updateFrom = (instance , from ) => {
3284
3284
 
3285
3285
 
3286
3286
 
3287
+
3287
3288
 
3288
3289
 
3289
3290
 
3290
3291
 
3291
3292
 
3293
+
3292
3294
 
3293
3295
 
3296
+
3294
3297
 
3295
3298
 
3296
3299
 
@@ -3307,6 +3310,7 @@ var updateFrom = (instance , from ) => {
3307
3310
 
3308
3311
 
3309
3312
 
3313
+
3310
3314
 
3311
3315
 
3312
3316
  class CallSession {
@@ -3326,10 +3330,14 @@ class CallSession {
3326
3330
 
3327
3331
 
3328
3332
 
3329
-
3333
+
3334
+
3335
+ // = creationTime
3330
3336
 
3331
3337
 
3332
3338
 
3339
+
3340
+
3333
3341
 
3334
3342
 
3335
3343
 
@@ -3365,6 +3373,8 @@ class CallSession {
3365
3373
 
3366
3374
 
3367
3375
 
3376
+
3377
+
3368
3378
 
3369
3379
  constructor({
3370
3380
  answered,
@@ -3378,6 +3388,8 @@ class CallSession {
3378
3388
  paused,
3379
3389
  ringing,
3380
3390
  startTime,
3391
+ creationTime,
3392
+ endTime,
3381
3393
  cameraEnabled,
3382
3394
  dialedExtension,
3383
3395
  sipCallId,
@@ -3390,12 +3402,16 @@ class CallSession {
3390
3402
  recording,
3391
3403
  recordingPaused,
3392
3404
  videoRemotelyDowngraded,
3405
+ sipSession,
3406
+ answerTime,
3393
3407
  } ) {
3394
3408
  this.callId = callId;
3395
3409
  this.sipCallId = sipCallId;
3396
3410
  this.displayName = displayName;
3397
3411
  this.number = number;
3412
+ this.creationTime = creationTime;
3398
3413
  this.startTime = startTime;
3414
+ this.endTime = endTime;
3399
3415
  this.isCaller = isCaller;
3400
3416
  this.answered = answered;
3401
3417
  this.answeredBySystem = answeredBySystem;
@@ -3414,6 +3430,8 @@ class CallSession {
3414
3430
  this.recording = recording || false;
3415
3431
  this.recordingPaused = recordingPaused || false;
3416
3432
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3433
+ this.sipSession = sipSession;
3434
+ this.answerTime = answerTime || this.answerTime;
3417
3435
 
3418
3436
  // Useful to compare instead of instanceof with minified code
3419
3437
  this.type = 'CallSession';
@@ -3444,7 +3462,7 @@ class CallSession {
3444
3462
  }
3445
3463
 
3446
3464
  answer() {
3447
- this.answered = true;
3465
+ this.answerTime = new Date();
3448
3466
  }
3449
3467
 
3450
3468
  systemAnswer() {
@@ -3600,6 +3618,15 @@ class CallSession {
3600
3618
  return newFrom(callSession, CallSession);
3601
3619
  }
3602
3620
 
3621
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3622
+ set answered(value ) {
3623
+ this.answerTime = value ? this.answerTime || new Date() : null;
3624
+ }
3625
+
3626
+ get answered() {
3627
+ return !!this.answerTime;
3628
+ }
3629
+
3603
3630
  static parseCall(call ) {
3604
3631
  return new CallSession({
3605
3632
  callId: call.id,
@@ -6620,6 +6647,7 @@ const MAX_REGISTER_TRIES = 10;
6620
6647
 
6621
6648
 
6622
6649
 
6650
+
6623
6651
 
6624
6652
 
6625
6653
 
@@ -8236,6 +8264,13 @@ class WebRTCClient extends Emitter {
8236
8264
  }
8237
8265
 
8238
8266
  _createWebRTCConfiguration(configOverrides = {}) {
8267
+ let { host } = this.config;
8268
+ let port = this.config.port || 443;
8269
+
8270
+ if (this.config.websocketSip) {
8271
+ [host, port = 443] = this.config.websocketSip.split(':');
8272
+ }
8273
+
8239
8274
  const config = {
8240
8275
  authorizationUsername: this.config.authorizationUser,
8241
8276
  authorizationPassword: this.config.password,
@@ -8271,7 +8306,7 @@ class WebRTCClient extends Emitter {
8271
8306
  },
8272
8307
  transportOptions: {
8273
8308
  traceSip: configOverrides.traceSip || false,
8274
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8309
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8275
8310
  },
8276
8311
  sessionDescriptionHandlerFactoryOptions: {
8277
8312
  modifiers: [replaceLocalIpModifier],
@@ -8733,6 +8768,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8733
8768
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8734
8769
  const ON_CALL_CANCELED = 'onCallCanceled';
8735
8770
  const ON_CALL_FAILED = 'onCallFailed';
8771
+ const ON_CALL_REJECTED = 'onCallRejected';
8736
8772
  const ON_CALL_ENDED = 'onCallEnded';
8737
8773
  const ON_CALL_ENDING = 'onCallEnding';
8738
8774
  const ON_MESSAGE = 'onMessage';
@@ -8777,6 +8813,7 @@ const events = [
8777
8813
  ON_CAMERA_DISABLED,
8778
8814
  ON_CALL_FAILED,
8779
8815
  ON_CALL_ENDED,
8816
+ ON_CALL_REJECTED,
8780
8817
  ON_MESSAGE,
8781
8818
  ON_REINVITE,
8782
8819
  ON_TRACK,
@@ -9133,6 +9170,7 @@ class WebRTCPhone extends Emitter {
9133
9170
 
9134
9171
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9135
9172
  const callSession = this._createCallSession(sipSession);
9173
+ callSession.endTime = new Date();
9136
9174
  const wasCurrentSession = this._onCallTerminated(sipSession);
9137
9175
 
9138
9176
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9328,6 +9366,8 @@ class WebRTCPhone extends Emitter {
9328
9366
  this.removeIncomingSessions(sipSessionId);
9329
9367
  }
9330
9368
 
9369
+ callSession.answerTime = new Date();
9370
+ this._updateCallSession(callSession);
9331
9371
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9332
9372
 
9333
9373
  return callSession;
@@ -9543,6 +9583,8 @@ class WebRTCPhone extends Emitter {
9543
9583
  }
9544
9584
 
9545
9585
  this.shouldSendReinvite = false;
9586
+ callSession.answerTime = new Date();
9587
+ this._updateCallSession(callSession);
9546
9588
  this.acceptedSessions[callSession.getId()] = true;
9547
9589
 
9548
9590
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9642,7 +9684,7 @@ class WebRTCPhone extends Emitter {
9642
9684
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9643
9685
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9644
9686
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9645
- this.holdSipSession(this.currentSipSession, callSession);
9687
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9646
9688
  }
9647
9689
 
9648
9690
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9852,6 +9894,8 @@ class WebRTCPhone extends Emitter {
9852
9894
  return Promise.resolve(null);
9853
9895
  }
9854
9896
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9897
+ callSession.creationTime = new Date();
9898
+ this._updateCallSession(callSession);
9855
9899
 
9856
9900
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9857
9901
 
@@ -10130,6 +10174,9 @@ class WebRTCPhone extends Emitter {
10130
10174
  callSession);
10131
10175
  }
10132
10176
 
10177
+ callSession.creationTime = new Date();
10178
+ this._updateCallSession(callSession);
10179
+
10133
10180
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10134
10181
  });
10135
10182
 
@@ -10169,6 +10216,15 @@ class WebRTCPhone extends Emitter {
10169
10216
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10170
10217
  });
10171
10218
 
10219
+ this.client.on(this.client.REJECTED, session => {
10220
+ logger$7.info('WebRTC call rejected', session.id);
10221
+ const callSession = this._createCallSession(session);
10222
+ callSession.endTime = new Date();
10223
+ this._updateCallSession(callSession);
10224
+
10225
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10226
+ });
10227
+
10172
10228
  this.client.on(this.client.UNREGISTERED, () => {
10173
10229
  logger$7.info('WebRTC unregistered');
10174
10230
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10381,6 +10437,7 @@ class WebRTCPhone extends Emitter {
10381
10437
  const number = identity ? identity.uri._normal.user : null;
10382
10438
  const { state } = sipSession || {};
10383
10439
  const sessionId = this.getSipSessionId(sipSession);
10440
+ fromSession = fromSession || this.callSessions[sessionId];
10384
10441
 
10385
10442
  const callSession = new CallSession({
10386
10443
  callId: fromSession && fromSession.callId,
@@ -10388,6 +10445,9 @@ class WebRTCPhone extends Emitter {
10388
10445
  sipStatus: state,
10389
10446
  displayName: identity ? identity.displayName || number : number,
10390
10447
  startTime: fromSession ? fromSession.startTime : new Date(),
10448
+ creationTime: fromSession ? fromSession.creationTime : null,
10449
+ answerTime: fromSession ? fromSession.answerTime : null,
10450
+ endTime: fromSession ? fromSession.endTime : null,
10391
10451
  answered: state === sessionState.SessionState.Established,
10392
10452
  paused: this.client.isCallHeld(sipSession),
10393
10453
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10398,6 +10458,7 @@ class WebRTCPhone extends Emitter {
10398
10458
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10399
10459
  recording: fromSession ? fromSession.isRecording() : false,
10400
10460
  recordingPaused: false, // @TODO
10461
+ sipSession,
10401
10462
  ...extra,
10402
10463
  });
10403
10464
 
@@ -10426,6 +10487,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10426
10487
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10427
10488
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10428
10489
  ON_CALL_FAILED: ON_CALL_FAILED,
10490
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10429
10491
  ON_CALL_ENDED: ON_CALL_ENDED,
10430
10492
  ON_CALL_ENDING: ON_CALL_ENDING,
10431
10493
  ON_MESSAGE: ON_MESSAGE,
@@ -10455,6 +10517,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10455
10517
  'default': WebRTCPhone
10456
10518
  });
10457
10519
 
10520
+ /* */
10521
+ class SFUNotAvailableError extends Error {
10522
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10523
+ super(message);
10524
+ this.name = 'SFUNotAvailableError';
10525
+ }
10526
+ }
10527
+
10458
10528
  //
10459
10529
 
10460
10530
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10839,7 +10909,7 @@ class Phone extends Emitter {
10839
10909
 
10840
10910
  checkSfu() {
10841
10911
  if (!this.hasSfu()) {
10842
- throw new Error('Sorry your user is not configured to support video conference');
10912
+ throw new SFUNotAvailableError();
10843
10913
  }
10844
10914
  }
10845
10915
 
@@ -12621,6 +12691,7 @@ const Wazo = {
12621
12691
  InvalidSubscription,
12622
12692
  InvalidAuthorization,
12623
12693
  CanceledCallError,
12694
+ SFUNotAvailableError,
12624
12695
  };
12625
12696
 
12626
12697
  if (window) {
@@ -3284,13 +3284,16 @@ var updateFrom = (instance , from ) => {
3284
3284
 
3285
3285
 
3286
3286
 
3287
+
3287
3288
 
3288
3289
 
3289
3290
 
3290
3291
 
3291
3292
 
3293
+
3292
3294
 
3293
3295
 
3296
+
3294
3297
 
3295
3298
 
3296
3299
 
@@ -3307,6 +3310,7 @@ var updateFrom = (instance , from ) => {
3307
3310
 
3308
3311
 
3309
3312
 
3313
+
3310
3314
 
3311
3315
 
3312
3316
  class CallSession {
@@ -3326,10 +3330,14 @@ class CallSession {
3326
3330
 
3327
3331
 
3328
3332
 
3329
-
3333
+
3334
+
3335
+ // = creationTime
3330
3336
 
3331
3337
 
3332
3338
 
3339
+
3340
+
3333
3341
 
3334
3342
 
3335
3343
 
@@ -3365,6 +3373,8 @@ class CallSession {
3365
3373
 
3366
3374
 
3367
3375
 
3376
+
3377
+
3368
3378
 
3369
3379
  constructor({
3370
3380
  answered,
@@ -3378,6 +3388,8 @@ class CallSession {
3378
3388
  paused,
3379
3389
  ringing,
3380
3390
  startTime,
3391
+ creationTime,
3392
+ endTime,
3381
3393
  cameraEnabled,
3382
3394
  dialedExtension,
3383
3395
  sipCallId,
@@ -3390,12 +3402,16 @@ class CallSession {
3390
3402
  recording,
3391
3403
  recordingPaused,
3392
3404
  videoRemotelyDowngraded,
3405
+ sipSession,
3406
+ answerTime,
3393
3407
  } ) {
3394
3408
  this.callId = callId;
3395
3409
  this.sipCallId = sipCallId;
3396
3410
  this.displayName = displayName;
3397
3411
  this.number = number;
3412
+ this.creationTime = creationTime;
3398
3413
  this.startTime = startTime;
3414
+ this.endTime = endTime;
3399
3415
  this.isCaller = isCaller;
3400
3416
  this.answered = answered;
3401
3417
  this.answeredBySystem = answeredBySystem;
@@ -3414,6 +3430,8 @@ class CallSession {
3414
3430
  this.recording = recording || false;
3415
3431
  this.recordingPaused = recordingPaused || false;
3416
3432
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3433
+ this.sipSession = sipSession;
3434
+ this.answerTime = answerTime || this.answerTime;
3417
3435
 
3418
3436
  // Useful to compare instead of instanceof with minified code
3419
3437
  this.type = 'CallSession';
@@ -3444,7 +3462,7 @@ class CallSession {
3444
3462
  }
3445
3463
 
3446
3464
  answer() {
3447
- this.answered = true;
3465
+ this.answerTime = new Date();
3448
3466
  }
3449
3467
 
3450
3468
  systemAnswer() {
@@ -3600,6 +3618,15 @@ class CallSession {
3600
3618
  return newFrom(callSession, CallSession);
3601
3619
  }
3602
3620
 
3621
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3622
+ set answered(value ) {
3623
+ this.answerTime = value ? this.answerTime || new Date() : null;
3624
+ }
3625
+
3626
+ get answered() {
3627
+ return !!this.answerTime;
3628
+ }
3629
+
3603
3630
  static parseCall(call ) {
3604
3631
  return new CallSession({
3605
3632
  callId: call.id,
@@ -6620,6 +6647,7 @@ const MAX_REGISTER_TRIES = 10;
6620
6647
 
6621
6648
 
6622
6649
 
6650
+
6623
6651
 
6624
6652
 
6625
6653
 
@@ -8236,6 +8264,13 @@ class WebRTCClient extends Emitter {
8236
8264
  }
8237
8265
 
8238
8266
  _createWebRTCConfiguration(configOverrides = {}) {
8267
+ let { host } = this.config;
8268
+ let port = this.config.port || 443;
8269
+
8270
+ if (this.config.websocketSip) {
8271
+ [host, port = 443] = this.config.websocketSip.split(':');
8272
+ }
8273
+
8239
8274
  const config = {
8240
8275
  authorizationUsername: this.config.authorizationUser,
8241
8276
  authorizationPassword: this.config.password,
@@ -8271,7 +8306,7 @@ class WebRTCClient extends Emitter {
8271
8306
  },
8272
8307
  transportOptions: {
8273
8308
  traceSip: configOverrides.traceSip || false,
8274
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8309
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8275
8310
  },
8276
8311
  sessionDescriptionHandlerFactoryOptions: {
8277
8312
  modifiers: [replaceLocalIpModifier],
@@ -8733,6 +8768,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8733
8768
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8734
8769
  const ON_CALL_CANCELED = 'onCallCanceled';
8735
8770
  const ON_CALL_FAILED = 'onCallFailed';
8771
+ const ON_CALL_REJECTED = 'onCallRejected';
8736
8772
  const ON_CALL_ENDED = 'onCallEnded';
8737
8773
  const ON_CALL_ENDING = 'onCallEnding';
8738
8774
  const ON_MESSAGE = 'onMessage';
@@ -8777,6 +8813,7 @@ const events = [
8777
8813
  ON_CAMERA_DISABLED,
8778
8814
  ON_CALL_FAILED,
8779
8815
  ON_CALL_ENDED,
8816
+ ON_CALL_REJECTED,
8780
8817
  ON_MESSAGE,
8781
8818
  ON_REINVITE,
8782
8819
  ON_TRACK,
@@ -9133,6 +9170,7 @@ class WebRTCPhone extends Emitter {
9133
9170
 
9134
9171
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9135
9172
  const callSession = this._createCallSession(sipSession);
9173
+ callSession.endTime = new Date();
9136
9174
  const wasCurrentSession = this._onCallTerminated(sipSession);
9137
9175
 
9138
9176
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9328,6 +9366,8 @@ class WebRTCPhone extends Emitter {
9328
9366
  this.removeIncomingSessions(sipSessionId);
9329
9367
  }
9330
9368
 
9369
+ callSession.answerTime = new Date();
9370
+ this._updateCallSession(callSession);
9331
9371
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9332
9372
 
9333
9373
  return callSession;
@@ -9543,6 +9583,8 @@ class WebRTCPhone extends Emitter {
9543
9583
  }
9544
9584
 
9545
9585
  this.shouldSendReinvite = false;
9586
+ callSession.answerTime = new Date();
9587
+ this._updateCallSession(callSession);
9546
9588
  this.acceptedSessions[callSession.getId()] = true;
9547
9589
 
9548
9590
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9642,7 +9684,7 @@ class WebRTCPhone extends Emitter {
9642
9684
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9643
9685
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9644
9686
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9645
- this.holdSipSession(this.currentSipSession, callSession);
9687
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9646
9688
  }
9647
9689
 
9648
9690
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9852,6 +9894,8 @@ class WebRTCPhone extends Emitter {
9852
9894
  return Promise.resolve(null);
9853
9895
  }
9854
9896
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9897
+ callSession.creationTime = new Date();
9898
+ this._updateCallSession(callSession);
9855
9899
 
9856
9900
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9857
9901
 
@@ -10130,6 +10174,9 @@ class WebRTCPhone extends Emitter {
10130
10174
  callSession);
10131
10175
  }
10132
10176
 
10177
+ callSession.creationTime = new Date();
10178
+ this._updateCallSession(callSession);
10179
+
10133
10180
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10134
10181
  });
10135
10182
 
@@ -10169,6 +10216,15 @@ class WebRTCPhone extends Emitter {
10169
10216
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10170
10217
  });
10171
10218
 
10219
+ this.client.on(this.client.REJECTED, session => {
10220
+ logger$7.info('WebRTC call rejected', session.id);
10221
+ const callSession = this._createCallSession(session);
10222
+ callSession.endTime = new Date();
10223
+ this._updateCallSession(callSession);
10224
+
10225
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10226
+ });
10227
+
10172
10228
  this.client.on(this.client.UNREGISTERED, () => {
10173
10229
  logger$7.info('WebRTC unregistered');
10174
10230
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10381,6 +10437,7 @@ class WebRTCPhone extends Emitter {
10381
10437
  const number = identity ? identity.uri._normal.user : null;
10382
10438
  const { state } = sipSession || {};
10383
10439
  const sessionId = this.getSipSessionId(sipSession);
10440
+ fromSession = fromSession || this.callSessions[sessionId];
10384
10441
 
10385
10442
  const callSession = new CallSession({
10386
10443
  callId: fromSession && fromSession.callId,
@@ -10388,6 +10445,9 @@ class WebRTCPhone extends Emitter {
10388
10445
  sipStatus: state,
10389
10446
  displayName: identity ? identity.displayName || number : number,
10390
10447
  startTime: fromSession ? fromSession.startTime : new Date(),
10448
+ creationTime: fromSession ? fromSession.creationTime : null,
10449
+ answerTime: fromSession ? fromSession.answerTime : null,
10450
+ endTime: fromSession ? fromSession.endTime : null,
10391
10451
  answered: state === sessionState.SessionState.Established,
10392
10452
  paused: this.client.isCallHeld(sipSession),
10393
10453
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10398,6 +10458,7 @@ class WebRTCPhone extends Emitter {
10398
10458
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10399
10459
  recording: fromSession ? fromSession.isRecording() : false,
10400
10460
  recordingPaused: false, // @TODO
10461
+ sipSession,
10401
10462
  ...extra,
10402
10463
  });
10403
10464
 
@@ -10426,6 +10487,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10426
10487
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10427
10488
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10428
10489
  ON_CALL_FAILED: ON_CALL_FAILED,
10490
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10429
10491
  ON_CALL_ENDED: ON_CALL_ENDED,
10430
10492
  ON_CALL_ENDING: ON_CALL_ENDING,
10431
10493
  ON_MESSAGE: ON_MESSAGE,
@@ -10455,6 +10517,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10455
10517
  'default': WebRTCPhone
10456
10518
  });
10457
10519
 
10520
+ /* */
10521
+ class SFUNotAvailableError extends Error {
10522
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10523
+ super(message);
10524
+ this.name = 'SFUNotAvailableError';
10525
+ }
10526
+ }
10527
+
10458
10528
  //
10459
10529
 
10460
10530
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10839,7 +10909,7 @@ class Phone extends Emitter {
10839
10909
 
10840
10910
  checkSfu() {
10841
10911
  if (!this.hasSfu()) {
10842
- throw new Error('Sorry your user is not configured to support video conference');
10912
+ throw new SFUNotAvailableError();
10843
10913
  }
10844
10914
  }
10845
10915
 
@@ -12626,6 +12696,7 @@ const Wazo = {
12626
12696
  InvalidSubscription,
12627
12697
  InvalidAuthorization,
12628
12698
  CanceledCallError,
12699
+ SFUNotAvailableError,
12629
12700
  };
12630
12701
 
12631
12702
  if (window) {