@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
@@ -248,13 +248,16 @@ var updateFrom = (instance , from ) => {
248
248
 
249
249
 
250
250
 
251
+
251
252
 
252
253
 
253
254
 
254
255
 
255
256
 
257
+
256
258
 
257
259
 
260
+
258
261
 
259
262
 
260
263
 
@@ -271,6 +274,7 @@ var updateFrom = (instance , from ) => {
271
274
 
272
275
 
273
276
 
277
+
274
278
 
275
279
 
276
280
  class CallSession {
@@ -290,10 +294,14 @@ class CallSession {
290
294
 
291
295
 
292
296
 
293
-
297
+
298
+
299
+ // = creationTime
294
300
 
295
301
 
296
302
 
303
+
304
+
297
305
 
298
306
 
299
307
 
@@ -329,6 +337,8 @@ class CallSession {
329
337
 
330
338
 
331
339
 
340
+
341
+
332
342
 
333
343
  constructor({
334
344
  answered,
@@ -342,6 +352,8 @@ class CallSession {
342
352
  paused,
343
353
  ringing,
344
354
  startTime,
355
+ creationTime,
356
+ endTime,
345
357
  cameraEnabled,
346
358
  dialedExtension,
347
359
  sipCallId,
@@ -354,12 +366,16 @@ class CallSession {
354
366
  recording,
355
367
  recordingPaused,
356
368
  videoRemotelyDowngraded,
369
+ sipSession,
370
+ answerTime,
357
371
  } ) {
358
372
  this.callId = callId;
359
373
  this.sipCallId = sipCallId;
360
374
  this.displayName = displayName;
361
375
  this.number = number;
376
+ this.creationTime = creationTime;
362
377
  this.startTime = startTime;
378
+ this.endTime = endTime;
363
379
  this.isCaller = isCaller;
364
380
  this.answered = answered;
365
381
  this.answeredBySystem = answeredBySystem;
@@ -378,6 +394,8 @@ class CallSession {
378
394
  this.recording = recording || false;
379
395
  this.recordingPaused = recordingPaused || false;
380
396
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
397
+ this.sipSession = sipSession;
398
+ this.answerTime = answerTime || this.answerTime;
381
399
 
382
400
  // Useful to compare instead of instanceof with minified code
383
401
  this.type = 'CallSession';
@@ -408,7 +426,7 @@ class CallSession {
408
426
  }
409
427
 
410
428
  answer() {
411
- this.answered = true;
429
+ this.answerTime = new Date();
412
430
  }
413
431
 
414
432
  systemAnswer() {
@@ -564,6 +582,15 @@ class CallSession {
564
582
  return newFrom(callSession, CallSession);
565
583
  }
566
584
 
585
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
586
+ set answered(value ) {
587
+ this.answerTime = value ? this.answerTime || new Date() : null;
588
+ }
589
+
590
+ get answered() {
591
+ return !!this.answerTime;
592
+ }
593
+
567
594
  static parseCall(call ) {
568
595
  return new CallSession({
569
596
  callId: call.id,
@@ -6346,6 +6373,7 @@ const MAX_REGISTER_TRIES = 10;
6346
6373
 
6347
6374
 
6348
6375
 
6376
+
6349
6377
 
6350
6378
 
6351
6379
 
@@ -7962,6 +7990,13 @@ class WebRTCClient extends Emitter {
7962
7990
  }
7963
7991
 
7964
7992
  _createWebRTCConfiguration(configOverrides = {}) {
7993
+ let { host } = this.config;
7994
+ let port = this.config.port || 443;
7995
+
7996
+ if (this.config.websocketSip) {
7997
+ [host, port = 443] = this.config.websocketSip.split(':');
7998
+ }
7999
+
7965
8000
  const config = {
7966
8001
  authorizationUsername: this.config.authorizationUser,
7967
8002
  authorizationPassword: this.config.password,
@@ -7997,7 +8032,7 @@ class WebRTCClient extends Emitter {
7997
8032
  },
7998
8033
  transportOptions: {
7999
8034
  traceSip: configOverrides.traceSip || false,
8000
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8035
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8001
8036
  },
8002
8037
  sessionDescriptionHandlerFactoryOptions: {
8003
8038
  modifiers: [replaceLocalIpModifier],
@@ -8459,6 +8494,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8459
8494
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8460
8495
  const ON_CALL_CANCELED = 'onCallCanceled';
8461
8496
  const ON_CALL_FAILED = 'onCallFailed';
8497
+ const ON_CALL_REJECTED = 'onCallRejected';
8462
8498
  const ON_CALL_ENDED = 'onCallEnded';
8463
8499
  const ON_CALL_ENDING = 'onCallEnding';
8464
8500
  const ON_MESSAGE = 'onMessage';
@@ -8503,6 +8539,7 @@ const events = [
8503
8539
  ON_CAMERA_DISABLED,
8504
8540
  ON_CALL_FAILED,
8505
8541
  ON_CALL_ENDED,
8542
+ ON_CALL_REJECTED,
8506
8543
  ON_MESSAGE,
8507
8544
  ON_REINVITE,
8508
8545
  ON_TRACK,
@@ -8859,6 +8896,7 @@ class WebRTCPhone extends Emitter {
8859
8896
 
8860
8897
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8861
8898
  const callSession = this._createCallSession(sipSession);
8899
+ callSession.endTime = new Date();
8862
8900
  const wasCurrentSession = this._onCallTerminated(sipSession);
8863
8901
 
8864
8902
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9054,6 +9092,8 @@ class WebRTCPhone extends Emitter {
9054
9092
  this.removeIncomingSessions(sipSessionId);
9055
9093
  }
9056
9094
 
9095
+ callSession.answerTime = new Date();
9096
+ this._updateCallSession(callSession);
9057
9097
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9058
9098
 
9059
9099
  return callSession;
@@ -9269,6 +9309,8 @@ class WebRTCPhone extends Emitter {
9269
9309
  }
9270
9310
 
9271
9311
  this.shouldSendReinvite = false;
9312
+ callSession.answerTime = new Date();
9313
+ this._updateCallSession(callSession);
9272
9314
  this.acceptedSessions[callSession.getId()] = true;
9273
9315
 
9274
9316
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9368,7 +9410,7 @@ class WebRTCPhone extends Emitter {
9368
9410
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9369
9411
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9370
9412
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9371
- this.holdSipSession(this.currentSipSession, callSession);
9413
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9372
9414
  }
9373
9415
 
9374
9416
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9578,6 +9620,8 @@ class WebRTCPhone extends Emitter {
9578
9620
  return Promise.resolve(null);
9579
9621
  }
9580
9622
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9623
+ callSession.creationTime = new Date();
9624
+ this._updateCallSession(callSession);
9581
9625
 
9582
9626
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9583
9627
 
@@ -9856,6 +9900,9 @@ class WebRTCPhone extends Emitter {
9856
9900
  callSession);
9857
9901
  }
9858
9902
 
9903
+ callSession.creationTime = new Date();
9904
+ this._updateCallSession(callSession);
9905
+
9859
9906
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9860
9907
  });
9861
9908
 
@@ -9895,6 +9942,15 @@ class WebRTCPhone extends Emitter {
9895
9942
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9896
9943
  });
9897
9944
 
9945
+ this.client.on(this.client.REJECTED, session => {
9946
+ logger$8.info('WebRTC call rejected', session.id);
9947
+ const callSession = this._createCallSession(session);
9948
+ callSession.endTime = new Date();
9949
+ this._updateCallSession(callSession);
9950
+
9951
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9952
+ });
9953
+
9898
9954
  this.client.on(this.client.UNREGISTERED, () => {
9899
9955
  logger$8.info('WebRTC unregistered');
9900
9956
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10107,6 +10163,7 @@ class WebRTCPhone extends Emitter {
10107
10163
  const number = identity ? identity.uri._normal.user : null;
10108
10164
  const { state } = sipSession || {};
10109
10165
  const sessionId = this.getSipSessionId(sipSession);
10166
+ fromSession = fromSession || this.callSessions[sessionId];
10110
10167
 
10111
10168
  const callSession = new CallSession({
10112
10169
  callId: fromSession && fromSession.callId,
@@ -10114,6 +10171,9 @@ class WebRTCPhone extends Emitter {
10114
10171
  sipStatus: state,
10115
10172
  displayName: identity ? identity.displayName || number : number,
10116
10173
  startTime: fromSession ? fromSession.startTime : new Date(),
10174
+ creationTime: fromSession ? fromSession.creationTime : null,
10175
+ answerTime: fromSession ? fromSession.answerTime : null,
10176
+ endTime: fromSession ? fromSession.endTime : null,
10117
10177
  answered: state === SessionState.Established,
10118
10178
  paused: this.client.isCallHeld(sipSession),
10119
10179
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10124,6 +10184,7 @@ class WebRTCPhone extends Emitter {
10124
10184
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10125
10185
  recording: fromSession ? fromSession.isRecording() : false,
10126
10186
  recordingPaused: false, // @TODO
10187
+ sipSession,
10127
10188
  ...extra,
10128
10189
  });
10129
10190
 
@@ -10152,6 +10213,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10152
10213
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10153
10214
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10154
10215
  ON_CALL_FAILED: ON_CALL_FAILED,
10216
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10155
10217
  ON_CALL_ENDED: ON_CALL_ENDED,
10156
10218
  ON_CALL_ENDING: ON_CALL_ENDING,
10157
10219
  ON_MESSAGE: ON_MESSAGE,
@@ -12431,6 +12493,14 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
12431
12493
 
12432
12494
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
12433
12495
 
12496
+ /* */
12497
+ class SFUNotAvailableError extends Error {
12498
+ constructor(message = 'Sorry your user is not configured to support video conference') {
12499
+ super(message);
12500
+ this.name = 'SFUNotAvailableError';
12501
+ }
12502
+ }
12503
+
12434
12504
  //
12435
12505
 
12436
12506
 
@@ -13332,6 +13402,7 @@ const Wazo = {
13332
13402
  InvalidSubscription,
13333
13403
  InvalidAuthorization,
13334
13404
  CanceledCallError,
13405
+ SFUNotAvailableError,
13335
13406
  };
13336
13407
 
13337
13408
  if (window) {
@@ -13725,7 +13796,7 @@ class Phone extends Emitter {
13725
13796
 
13726
13797
  checkSfu() {
13727
13798
  if (!this.hasSfu()) {
13728
- throw new Error('Sorry your user is not configured to support video conference');
13799
+ throw new SFUNotAvailableError();
13729
13800
  }
13730
13801
  }
13731
13802
 
@@ -3248,13 +3248,16 @@ var updateFrom = (instance , from ) => {
3248
3248
 
3249
3249
 
3250
3250
 
3251
+
3251
3252
 
3252
3253
 
3253
3254
 
3254
3255
 
3255
3256
 
3257
+
3256
3258
 
3257
3259
 
3260
+
3258
3261
 
3259
3262
 
3260
3263
 
@@ -3271,6 +3274,7 @@ var updateFrom = (instance , from ) => {
3271
3274
 
3272
3275
 
3273
3276
 
3277
+
3274
3278
 
3275
3279
 
3276
3280
  class CallSession {
@@ -3290,10 +3294,14 @@ class CallSession {
3290
3294
 
3291
3295
 
3292
3296
 
3293
-
3297
+
3298
+
3299
+ // = creationTime
3294
3300
 
3295
3301
 
3296
3302
 
3303
+
3304
+
3297
3305
 
3298
3306
 
3299
3307
 
@@ -3329,6 +3337,8 @@ class CallSession {
3329
3337
 
3330
3338
 
3331
3339
 
3340
+
3341
+
3332
3342
 
3333
3343
  constructor({
3334
3344
  answered,
@@ -3342,6 +3352,8 @@ class CallSession {
3342
3352
  paused,
3343
3353
  ringing,
3344
3354
  startTime,
3355
+ creationTime,
3356
+ endTime,
3345
3357
  cameraEnabled,
3346
3358
  dialedExtension,
3347
3359
  sipCallId,
@@ -3354,12 +3366,16 @@ class CallSession {
3354
3366
  recording,
3355
3367
  recordingPaused,
3356
3368
  videoRemotelyDowngraded,
3369
+ sipSession,
3370
+ answerTime,
3357
3371
  } ) {
3358
3372
  this.callId = callId;
3359
3373
  this.sipCallId = sipCallId;
3360
3374
  this.displayName = displayName;
3361
3375
  this.number = number;
3376
+ this.creationTime = creationTime;
3362
3377
  this.startTime = startTime;
3378
+ this.endTime = endTime;
3363
3379
  this.isCaller = isCaller;
3364
3380
  this.answered = answered;
3365
3381
  this.answeredBySystem = answeredBySystem;
@@ -3378,6 +3394,8 @@ class CallSession {
3378
3394
  this.recording = recording || false;
3379
3395
  this.recordingPaused = recordingPaused || false;
3380
3396
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3397
+ this.sipSession = sipSession;
3398
+ this.answerTime = answerTime || this.answerTime;
3381
3399
 
3382
3400
  // Useful to compare instead of instanceof with minified code
3383
3401
  this.type = 'CallSession';
@@ -3408,7 +3426,7 @@ class CallSession {
3408
3426
  }
3409
3427
 
3410
3428
  answer() {
3411
- this.answered = true;
3429
+ this.answerTime = new Date();
3412
3430
  }
3413
3431
 
3414
3432
  systemAnswer() {
@@ -3564,6 +3582,15 @@ class CallSession {
3564
3582
  return newFrom(callSession, CallSession);
3565
3583
  }
3566
3584
 
3585
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3586
+ set answered(value ) {
3587
+ this.answerTime = value ? this.answerTime || new Date() : null;
3588
+ }
3589
+
3590
+ get answered() {
3591
+ return !!this.answerTime;
3592
+ }
3593
+
3567
3594
  static parseCall(call ) {
3568
3595
  return new CallSession({
3569
3596
  callId: call.id,
@@ -6610,6 +6637,7 @@ const MAX_REGISTER_TRIES = 10;
6610
6637
 
6611
6638
 
6612
6639
 
6640
+
6613
6641
 
6614
6642
 
6615
6643
 
@@ -8226,6 +8254,13 @@ class WebRTCClient extends Emitter {
8226
8254
  }
8227
8255
 
8228
8256
  _createWebRTCConfiguration(configOverrides = {}) {
8257
+ let { host } = this.config;
8258
+ let port = this.config.port || 443;
8259
+
8260
+ if (this.config.websocketSip) {
8261
+ [host, port = 443] = this.config.websocketSip.split(':');
8262
+ }
8263
+
8229
8264
  const config = {
8230
8265
  authorizationUsername: this.config.authorizationUser,
8231
8266
  authorizationPassword: this.config.password,
@@ -8261,7 +8296,7 @@ class WebRTCClient extends Emitter {
8261
8296
  },
8262
8297
  transportOptions: {
8263
8298
  traceSip: configOverrides.traceSip || false,
8264
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8299
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8265
8300
  },
8266
8301
  sessionDescriptionHandlerFactoryOptions: {
8267
8302
  modifiers: [replaceLocalIpModifier],
@@ -8723,6 +8758,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8723
8758
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8724
8759
  const ON_CALL_CANCELED = 'onCallCanceled';
8725
8760
  const ON_CALL_FAILED = 'onCallFailed';
8761
+ const ON_CALL_REJECTED = 'onCallRejected';
8726
8762
  const ON_CALL_ENDED = 'onCallEnded';
8727
8763
  const ON_CALL_ENDING = 'onCallEnding';
8728
8764
  const ON_MESSAGE = 'onMessage';
@@ -8767,6 +8803,7 @@ const events = [
8767
8803
  ON_CAMERA_DISABLED,
8768
8804
  ON_CALL_FAILED,
8769
8805
  ON_CALL_ENDED,
8806
+ ON_CALL_REJECTED,
8770
8807
  ON_MESSAGE,
8771
8808
  ON_REINVITE,
8772
8809
  ON_TRACK,
@@ -9123,6 +9160,7 @@ class WebRTCPhone extends Emitter {
9123
9160
 
9124
9161
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9125
9162
  const callSession = this._createCallSession(sipSession);
9163
+ callSession.endTime = new Date();
9126
9164
  const wasCurrentSession = this._onCallTerminated(sipSession);
9127
9165
 
9128
9166
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9318,6 +9356,8 @@ class WebRTCPhone extends Emitter {
9318
9356
  this.removeIncomingSessions(sipSessionId);
9319
9357
  }
9320
9358
 
9359
+ callSession.answerTime = new Date();
9360
+ this._updateCallSession(callSession);
9321
9361
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9322
9362
 
9323
9363
  return callSession;
@@ -9533,6 +9573,8 @@ class WebRTCPhone extends Emitter {
9533
9573
  }
9534
9574
 
9535
9575
  this.shouldSendReinvite = false;
9576
+ callSession.answerTime = new Date();
9577
+ this._updateCallSession(callSession);
9536
9578
  this.acceptedSessions[callSession.getId()] = true;
9537
9579
 
9538
9580
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9632,7 +9674,7 @@ class WebRTCPhone extends Emitter {
9632
9674
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9633
9675
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9634
9676
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9635
- this.holdSipSession(this.currentSipSession, callSession);
9677
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9636
9678
  }
9637
9679
 
9638
9680
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9842,6 +9884,8 @@ class WebRTCPhone extends Emitter {
9842
9884
  return Promise.resolve(null);
9843
9885
  }
9844
9886
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9887
+ callSession.creationTime = new Date();
9888
+ this._updateCallSession(callSession);
9845
9889
 
9846
9890
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9847
9891
 
@@ -10120,6 +10164,9 @@ class WebRTCPhone extends Emitter {
10120
10164
  callSession);
10121
10165
  }
10122
10166
 
10167
+ callSession.creationTime = new Date();
10168
+ this._updateCallSession(callSession);
10169
+
10123
10170
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10124
10171
  });
10125
10172
 
@@ -10159,6 +10206,15 @@ class WebRTCPhone extends Emitter {
10159
10206
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10160
10207
  });
10161
10208
 
10209
+ this.client.on(this.client.REJECTED, session => {
10210
+ logger$7.info('WebRTC call rejected', session.id);
10211
+ const callSession = this._createCallSession(session);
10212
+ callSession.endTime = new Date();
10213
+ this._updateCallSession(callSession);
10214
+
10215
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10216
+ });
10217
+
10162
10218
  this.client.on(this.client.UNREGISTERED, () => {
10163
10219
  logger$7.info('WebRTC unregistered');
10164
10220
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10371,6 +10427,7 @@ class WebRTCPhone extends Emitter {
10371
10427
  const number = identity ? identity.uri._normal.user : null;
10372
10428
  const { state } = sipSession || {};
10373
10429
  const sessionId = this.getSipSessionId(sipSession);
10430
+ fromSession = fromSession || this.callSessions[sessionId];
10374
10431
 
10375
10432
  const callSession = new CallSession({
10376
10433
  callId: fromSession && fromSession.callId,
@@ -10378,6 +10435,9 @@ class WebRTCPhone extends Emitter {
10378
10435
  sipStatus: state,
10379
10436
  displayName: identity ? identity.displayName || number : number,
10380
10437
  startTime: fromSession ? fromSession.startTime : new Date(),
10438
+ creationTime: fromSession ? fromSession.creationTime : null,
10439
+ answerTime: fromSession ? fromSession.answerTime : null,
10440
+ endTime: fromSession ? fromSession.endTime : null,
10381
10441
  answered: state === SessionState.Established,
10382
10442
  paused: this.client.isCallHeld(sipSession),
10383
10443
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10388,6 +10448,7 @@ class WebRTCPhone extends Emitter {
10388
10448
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10389
10449
  recording: fromSession ? fromSession.isRecording() : false,
10390
10450
  recordingPaused: false, // @TODO
10451
+ sipSession,
10391
10452
  ...extra,
10392
10453
  });
10393
10454
 
@@ -10416,6 +10477,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10416
10477
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10417
10478
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10418
10479
  ON_CALL_FAILED: ON_CALL_FAILED,
10480
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10419
10481
  ON_CALL_ENDED: ON_CALL_ENDED,
10420
10482
  ON_CALL_ENDING: ON_CALL_ENDING,
10421
10483
  ON_MESSAGE: ON_MESSAGE,
@@ -10445,6 +10507,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10445
10507
  'default': WebRTCPhone
10446
10508
  });
10447
10509
 
10510
+ /* */
10511
+ class SFUNotAvailableError extends Error {
10512
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10513
+ super(message);
10514
+ this.name = 'SFUNotAvailableError';
10515
+ }
10516
+ }
10517
+
10448
10518
  //
10449
10519
 
10450
10520
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10829,7 +10899,7 @@ class Phone extends Emitter {
10829
10899
 
10830
10900
  checkSfu() {
10831
10901
  if (!this.hasSfu()) {
10832
- throw new Error('Sorry your user is not configured to support video conference');
10902
+ throw new SFUNotAvailableError();
10833
10903
  }
10834
10904
  }
10835
10905
 
@@ -13742,6 +13812,7 @@ const Wazo = {
13742
13812
  InvalidSubscription,
13743
13813
  InvalidAuthorization,
13744
13814
  CanceledCallError,
13815
+ SFUNotAvailableError,
13745
13816
  };
13746
13817
 
13747
13818
  if (window) {