@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
@@ -258,13 +258,16 @@ var updateFrom = (instance , from ) => {
258
258
 
259
259
 
260
260
 
261
+
261
262
 
262
263
 
263
264
 
264
265
 
265
266
 
267
+
266
268
 
267
269
 
270
+
268
271
 
269
272
 
270
273
 
@@ -281,6 +284,7 @@ var updateFrom = (instance , from ) => {
281
284
 
282
285
 
283
286
 
287
+
284
288
 
285
289
 
286
290
  class CallSession {
@@ -300,10 +304,14 @@ class CallSession {
300
304
 
301
305
 
302
306
 
303
-
307
+
308
+
309
+ // = creationTime
304
310
 
305
311
 
306
312
 
313
+
314
+
307
315
 
308
316
 
309
317
 
@@ -339,6 +347,8 @@ class CallSession {
339
347
 
340
348
 
341
349
 
350
+
351
+
342
352
 
343
353
  constructor({
344
354
  answered,
@@ -352,6 +362,8 @@ class CallSession {
352
362
  paused,
353
363
  ringing,
354
364
  startTime,
365
+ creationTime,
366
+ endTime,
355
367
  cameraEnabled,
356
368
  dialedExtension,
357
369
  sipCallId,
@@ -364,12 +376,16 @@ class CallSession {
364
376
  recording,
365
377
  recordingPaused,
366
378
  videoRemotelyDowngraded,
379
+ sipSession,
380
+ answerTime,
367
381
  } ) {
368
382
  this.callId = callId;
369
383
  this.sipCallId = sipCallId;
370
384
  this.displayName = displayName;
371
385
  this.number = number;
386
+ this.creationTime = creationTime;
372
387
  this.startTime = startTime;
388
+ this.endTime = endTime;
373
389
  this.isCaller = isCaller;
374
390
  this.answered = answered;
375
391
  this.answeredBySystem = answeredBySystem;
@@ -388,6 +404,8 @@ class CallSession {
388
404
  this.recording = recording || false;
389
405
  this.recordingPaused = recordingPaused || false;
390
406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
407
+ this.sipSession = sipSession;
408
+ this.answerTime = answerTime || this.answerTime;
391
409
 
392
410
  // Useful to compare instead of instanceof with minified code
393
411
  this.type = 'CallSession';
@@ -418,7 +436,7 @@ class CallSession {
418
436
  }
419
437
 
420
438
  answer() {
421
- this.answered = true;
439
+ this.answerTime = new Date();
422
440
  }
423
441
 
424
442
  systemAnswer() {
@@ -574,6 +592,15 @@ class CallSession {
574
592
  return newFrom(callSession, CallSession);
575
593
  }
576
594
 
595
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
596
+ set answered(value ) {
597
+ this.answerTime = value ? this.answerTime || new Date() : null;
598
+ }
599
+
600
+ get answered() {
601
+ return !!this.answerTime;
602
+ }
603
+
577
604
  static parseCall(call ) {
578
605
  return new CallSession({
579
606
  callId: call.id,
@@ -6356,6 +6383,7 @@ const MAX_REGISTER_TRIES = 10;
6356
6383
 
6357
6384
 
6358
6385
 
6386
+
6359
6387
 
6360
6388
 
6361
6389
 
@@ -7972,6 +8000,13 @@ class WebRTCClient extends Emitter {
7972
8000
  }
7973
8001
 
7974
8002
  _createWebRTCConfiguration(configOverrides = {}) {
8003
+ let { host } = this.config;
8004
+ let port = this.config.port || 443;
8005
+
8006
+ if (this.config.websocketSip) {
8007
+ [host, port = 443] = this.config.websocketSip.split(':');
8008
+ }
8009
+
7975
8010
  const config = {
7976
8011
  authorizationUsername: this.config.authorizationUser,
7977
8012
  authorizationPassword: this.config.password,
@@ -8007,7 +8042,7 @@ class WebRTCClient extends Emitter {
8007
8042
  },
8008
8043
  transportOptions: {
8009
8044
  traceSip: configOverrides.traceSip || false,
8010
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8045
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8011
8046
  },
8012
8047
  sessionDescriptionHandlerFactoryOptions: {
8013
8048
  modifiers: [replaceLocalIpModifier],
@@ -8469,6 +8504,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8469
8504
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8470
8505
  const ON_CALL_CANCELED = 'onCallCanceled';
8471
8506
  const ON_CALL_FAILED = 'onCallFailed';
8507
+ const ON_CALL_REJECTED = 'onCallRejected';
8472
8508
  const ON_CALL_ENDED = 'onCallEnded';
8473
8509
  const ON_CALL_ENDING = 'onCallEnding';
8474
8510
  const ON_MESSAGE = 'onMessage';
@@ -8513,6 +8549,7 @@ const events = [
8513
8549
  ON_CAMERA_DISABLED,
8514
8550
  ON_CALL_FAILED,
8515
8551
  ON_CALL_ENDED,
8552
+ ON_CALL_REJECTED,
8516
8553
  ON_MESSAGE,
8517
8554
  ON_REINVITE,
8518
8555
  ON_TRACK,
@@ -8869,6 +8906,7 @@ class WebRTCPhone extends Emitter {
8869
8906
 
8870
8907
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8871
8908
  const callSession = this._createCallSession(sipSession);
8909
+ callSession.endTime = new Date();
8872
8910
  const wasCurrentSession = this._onCallTerminated(sipSession);
8873
8911
 
8874
8912
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9064,6 +9102,8 @@ class WebRTCPhone extends Emitter {
9064
9102
  this.removeIncomingSessions(sipSessionId);
9065
9103
  }
9066
9104
 
9105
+ callSession.answerTime = new Date();
9106
+ this._updateCallSession(callSession);
9067
9107
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9068
9108
 
9069
9109
  return callSession;
@@ -9279,6 +9319,8 @@ class WebRTCPhone extends Emitter {
9279
9319
  }
9280
9320
 
9281
9321
  this.shouldSendReinvite = false;
9322
+ callSession.answerTime = new Date();
9323
+ this._updateCallSession(callSession);
9282
9324
  this.acceptedSessions[callSession.getId()] = true;
9283
9325
 
9284
9326
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9378,7 +9420,7 @@ class WebRTCPhone extends Emitter {
9378
9420
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9379
9421
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9380
9422
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9381
- this.holdSipSession(this.currentSipSession, callSession);
9423
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9382
9424
  }
9383
9425
 
9384
9426
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9588,6 +9630,8 @@ class WebRTCPhone extends Emitter {
9588
9630
  return Promise.resolve(null);
9589
9631
  }
9590
9632
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9633
+ callSession.creationTime = new Date();
9634
+ this._updateCallSession(callSession);
9591
9635
 
9592
9636
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9593
9637
 
@@ -9866,6 +9910,9 @@ class WebRTCPhone extends Emitter {
9866
9910
  callSession);
9867
9911
  }
9868
9912
 
9913
+ callSession.creationTime = new Date();
9914
+ this._updateCallSession(callSession);
9915
+
9869
9916
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9870
9917
  });
9871
9918
 
@@ -9905,6 +9952,15 @@ class WebRTCPhone extends Emitter {
9905
9952
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9906
9953
  });
9907
9954
 
9955
+ this.client.on(this.client.REJECTED, session => {
9956
+ logger$8.info('WebRTC call rejected', session.id);
9957
+ const callSession = this._createCallSession(session);
9958
+ callSession.endTime = new Date();
9959
+ this._updateCallSession(callSession);
9960
+
9961
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9962
+ });
9963
+
9908
9964
  this.client.on(this.client.UNREGISTERED, () => {
9909
9965
  logger$8.info('WebRTC unregistered');
9910
9966
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10117,6 +10173,7 @@ class WebRTCPhone extends Emitter {
10117
10173
  const number = identity ? identity.uri._normal.user : null;
10118
10174
  const { state } = sipSession || {};
10119
10175
  const sessionId = this.getSipSessionId(sipSession);
10176
+ fromSession = fromSession || this.callSessions[sessionId];
10120
10177
 
10121
10178
  const callSession = new CallSession({
10122
10179
  callId: fromSession && fromSession.callId,
@@ -10124,6 +10181,9 @@ class WebRTCPhone extends Emitter {
10124
10181
  sipStatus: state,
10125
10182
  displayName: identity ? identity.displayName || number : number,
10126
10183
  startTime: fromSession ? fromSession.startTime : new Date(),
10184
+ creationTime: fromSession ? fromSession.creationTime : null,
10185
+ answerTime: fromSession ? fromSession.answerTime : null,
10186
+ endTime: fromSession ? fromSession.endTime : null,
10127
10187
  answered: state === sessionState.SessionState.Established,
10128
10188
  paused: this.client.isCallHeld(sipSession),
10129
10189
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10134,6 +10194,7 @@ class WebRTCPhone extends Emitter {
10134
10194
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10135
10195
  recording: fromSession ? fromSession.isRecording() : false,
10136
10196
  recordingPaused: false, // @TODO
10197
+ sipSession,
10137
10198
  ...extra,
10138
10199
  });
10139
10200
 
@@ -10162,6 +10223,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10162
10223
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10163
10224
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10164
10225
  ON_CALL_FAILED: ON_CALL_FAILED,
10226
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10165
10227
  ON_CALL_ENDED: ON_CALL_ENDED,
10166
10228
  ON_CALL_ENDING: ON_CALL_ENDING,
10167
10229
  ON_MESSAGE: ON_MESSAGE,
@@ -12441,6 +12503,14 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
12441
12503
 
12442
12504
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
12443
12505
 
12506
+ /* */
12507
+ class SFUNotAvailableError extends Error {
12508
+ constructor(message = 'Sorry your user is not configured to support video conference') {
12509
+ super(message);
12510
+ this.name = 'SFUNotAvailableError';
12511
+ }
12512
+ }
12513
+
12444
12514
  //
12445
12515
 
12446
12516
 
@@ -13342,6 +13412,7 @@ const Wazo = {
13342
13412
  InvalidSubscription,
13343
13413
  InvalidAuthorization,
13344
13414
  CanceledCallError,
13415
+ SFUNotAvailableError,
13345
13416
  };
13346
13417
 
13347
13418
  if (window) {
@@ -13735,7 +13806,7 @@ class Phone extends Emitter {
13735
13806
 
13736
13807
  checkSfu() {
13737
13808
  if (!this.hasSfu()) {
13738
- throw new Error('Sorry your user is not configured to support video conference');
13809
+ throw new SFUNotAvailableError();
13739
13810
  }
13740
13811
  }
13741
13812
 
@@ -3258,13 +3258,16 @@ var updateFrom = (instance , from ) => {
3258
3258
 
3259
3259
 
3260
3260
 
3261
+
3261
3262
 
3262
3263
 
3263
3264
 
3264
3265
 
3265
3266
 
3267
+
3266
3268
 
3267
3269
 
3270
+
3268
3271
 
3269
3272
 
3270
3273
 
@@ -3281,6 +3284,7 @@ var updateFrom = (instance , from ) => {
3281
3284
 
3282
3285
 
3283
3286
 
3287
+
3284
3288
 
3285
3289
 
3286
3290
  class CallSession {
@@ -3300,10 +3304,14 @@ class CallSession {
3300
3304
 
3301
3305
 
3302
3306
 
3303
-
3307
+
3308
+
3309
+ // = creationTime
3304
3310
 
3305
3311
 
3306
3312
 
3313
+
3314
+
3307
3315
 
3308
3316
 
3309
3317
 
@@ -3339,6 +3347,8 @@ class CallSession {
3339
3347
 
3340
3348
 
3341
3349
 
3350
+
3351
+
3342
3352
 
3343
3353
  constructor({
3344
3354
  answered,
@@ -3352,6 +3362,8 @@ class CallSession {
3352
3362
  paused,
3353
3363
  ringing,
3354
3364
  startTime,
3365
+ creationTime,
3366
+ endTime,
3355
3367
  cameraEnabled,
3356
3368
  dialedExtension,
3357
3369
  sipCallId,
@@ -3364,12 +3376,16 @@ class CallSession {
3364
3376
  recording,
3365
3377
  recordingPaused,
3366
3378
  videoRemotelyDowngraded,
3379
+ sipSession,
3380
+ answerTime,
3367
3381
  } ) {
3368
3382
  this.callId = callId;
3369
3383
  this.sipCallId = sipCallId;
3370
3384
  this.displayName = displayName;
3371
3385
  this.number = number;
3386
+ this.creationTime = creationTime;
3372
3387
  this.startTime = startTime;
3388
+ this.endTime = endTime;
3373
3389
  this.isCaller = isCaller;
3374
3390
  this.answered = answered;
3375
3391
  this.answeredBySystem = answeredBySystem;
@@ -3388,6 +3404,8 @@ class CallSession {
3388
3404
  this.recording = recording || false;
3389
3405
  this.recordingPaused = recordingPaused || false;
3390
3406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
+ this.sipSession = sipSession;
3408
+ this.answerTime = answerTime || this.answerTime;
3391
3409
 
3392
3410
  // Useful to compare instead of instanceof with minified code
3393
3411
  this.type = 'CallSession';
@@ -3418,7 +3436,7 @@ class CallSession {
3418
3436
  }
3419
3437
 
3420
3438
  answer() {
3421
- this.answered = true;
3439
+ this.answerTime = new Date();
3422
3440
  }
3423
3441
 
3424
3442
  systemAnswer() {
@@ -3574,6 +3592,15 @@ class CallSession {
3574
3592
  return newFrom(callSession, CallSession);
3575
3593
  }
3576
3594
 
3595
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3596
+ set answered(value ) {
3597
+ this.answerTime = value ? this.answerTime || new Date() : null;
3598
+ }
3599
+
3600
+ get answered() {
3601
+ return !!this.answerTime;
3602
+ }
3603
+
3577
3604
  static parseCall(call ) {
3578
3605
  return new CallSession({
3579
3606
  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
 
@@ -13752,6 +13822,7 @@ const Wazo = {
13752
13822
  InvalidSubscription,
13753
13823
  InvalidAuthorization,
13754
13824
  CanceledCallError,
13825
+ SFUNotAvailableError,
13755
13826
  };
13756
13827
 
13757
13828
  if (window) {