@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
@@ -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) {
@@ -3260,13 +3260,16 @@ var updateFrom = (instance , from ) => {
3260
3260
 
3261
3261
 
3262
3262
 
3263
+
3263
3264
 
3264
3265
 
3265
3266
 
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3272
+
3270
3273
 
3271
3274
 
3272
3275
 
@@ -3283,6 +3286,7 @@ var updateFrom = (instance , from ) => {
3283
3286
 
3284
3287
 
3285
3288
 
3289
+
3286
3290
 
3287
3291
 
3288
3292
  class CallSession {
@@ -3302,10 +3306,14 @@ class CallSession {
3302
3306
 
3303
3307
 
3304
3308
 
3305
-
3309
+
3310
+
3311
+ // = creationTime
3306
3312
 
3307
3313
 
3308
3314
 
3315
+
3316
+
3309
3317
 
3310
3318
 
3311
3319
 
@@ -3341,6 +3349,8 @@ class CallSession {
3341
3349
 
3342
3350
 
3343
3351
 
3352
+
3353
+
3344
3354
 
3345
3355
  constructor({
3346
3356
  answered,
@@ -3354,6 +3364,8 @@ class CallSession {
3354
3364
  paused,
3355
3365
  ringing,
3356
3366
  startTime,
3367
+ creationTime,
3368
+ endTime,
3357
3369
  cameraEnabled,
3358
3370
  dialedExtension,
3359
3371
  sipCallId,
@@ -3366,12 +3378,16 @@ class CallSession {
3366
3378
  recording,
3367
3379
  recordingPaused,
3368
3380
  videoRemotelyDowngraded,
3381
+ sipSession,
3382
+ answerTime,
3369
3383
  } ) {
3370
3384
  this.callId = callId;
3371
3385
  this.sipCallId = sipCallId;
3372
3386
  this.displayName = displayName;
3373
3387
  this.number = number;
3388
+ this.creationTime = creationTime;
3374
3389
  this.startTime = startTime;
3390
+ this.endTime = endTime;
3375
3391
  this.isCaller = isCaller;
3376
3392
  this.answered = answered;
3377
3393
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3406,8 @@ class CallSession {
3390
3406
  this.recording = recording || false;
3391
3407
  this.recordingPaused = recordingPaused || false;
3392
3408
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3409
+ this.sipSession = sipSession;
3410
+ this.answerTime = answerTime || this.answerTime;
3393
3411
 
3394
3412
  // Useful to compare instead of instanceof with minified code
3395
3413
  this.type = 'CallSession';
@@ -3420,7 +3438,7 @@ class CallSession {
3420
3438
  }
3421
3439
 
3422
3440
  answer() {
3423
- this.answered = true;
3441
+ this.answerTime = new Date();
3424
3442
  }
3425
3443
 
3426
3444
  systemAnswer() {
@@ -3576,6 +3594,15 @@ class CallSession {
3576
3594
  return newFrom(callSession, CallSession);
3577
3595
  }
3578
3596
 
3597
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3598
+ set answered(value ) {
3599
+ this.answerTime = value ? this.answerTime || new Date() : null;
3600
+ }
3601
+
3602
+ get answered() {
3603
+ return !!this.answerTime;
3604
+ }
3605
+
3579
3606
  static parseCall(call ) {
3580
3607
  return new CallSession({
3581
3608
  callId: call.id,
@@ -6622,6 +6649,7 @@ const MAX_REGISTER_TRIES = 10;
6622
6649
 
6623
6650
 
6624
6651
 
6652
+
6625
6653
 
6626
6654
 
6627
6655
 
@@ -8238,6 +8266,13 @@ class WebRTCClient extends Emitter {
8238
8266
  }
8239
8267
 
8240
8268
  _createWebRTCConfiguration(configOverrides = {}) {
8269
+ let { host } = this.config;
8270
+ let port = this.config.port || 443;
8271
+
8272
+ if (this.config.websocketSip) {
8273
+ [host, port = 443] = this.config.websocketSip.split(':');
8274
+ }
8275
+
8241
8276
  const config = {
8242
8277
  authorizationUsername: this.config.authorizationUser,
8243
8278
  authorizationPassword: this.config.password,
@@ -8273,7 +8308,7 @@ class WebRTCClient extends Emitter {
8273
8308
  },
8274
8309
  transportOptions: {
8275
8310
  traceSip: configOverrides.traceSip || false,
8276
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8311
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8277
8312
  },
8278
8313
  sessionDescriptionHandlerFactoryOptions: {
8279
8314
  modifiers: [replaceLocalIpModifier],
@@ -8735,6 +8770,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8735
8770
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8736
8771
  const ON_CALL_CANCELED = 'onCallCanceled';
8737
8772
  const ON_CALL_FAILED = 'onCallFailed';
8773
+ const ON_CALL_REJECTED = 'onCallRejected';
8738
8774
  const ON_CALL_ENDED = 'onCallEnded';
8739
8775
  const ON_CALL_ENDING = 'onCallEnding';
8740
8776
  const ON_MESSAGE = 'onMessage';
@@ -8779,6 +8815,7 @@ const events = [
8779
8815
  ON_CAMERA_DISABLED,
8780
8816
  ON_CALL_FAILED,
8781
8817
  ON_CALL_ENDED,
8818
+ ON_CALL_REJECTED,
8782
8819
  ON_MESSAGE,
8783
8820
  ON_REINVITE,
8784
8821
  ON_TRACK,
@@ -9135,6 +9172,7 @@ class WebRTCPhone extends Emitter {
9135
9172
 
9136
9173
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9137
9174
  const callSession = this._createCallSession(sipSession);
9175
+ callSession.endTime = new Date();
9138
9176
  const wasCurrentSession = this._onCallTerminated(sipSession);
9139
9177
 
9140
9178
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9330,6 +9368,8 @@ class WebRTCPhone extends Emitter {
9330
9368
  this.removeIncomingSessions(sipSessionId);
9331
9369
  }
9332
9370
 
9371
+ callSession.answerTime = new Date();
9372
+ this._updateCallSession(callSession);
9333
9373
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9334
9374
 
9335
9375
  return callSession;
@@ -9545,6 +9585,8 @@ class WebRTCPhone extends Emitter {
9545
9585
  }
9546
9586
 
9547
9587
  this.shouldSendReinvite = false;
9588
+ callSession.answerTime = new Date();
9589
+ this._updateCallSession(callSession);
9548
9590
  this.acceptedSessions[callSession.getId()] = true;
9549
9591
 
9550
9592
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9644,7 +9686,7 @@ class WebRTCPhone extends Emitter {
9644
9686
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9645
9687
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9646
9688
  logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9647
- this.holdSipSession(this.currentSipSession, callSession);
9689
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9648
9690
  }
9649
9691
 
9650
9692
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9854,6 +9896,8 @@ class WebRTCPhone extends Emitter {
9854
9896
  return Promise.resolve(null);
9855
9897
  }
9856
9898
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9899
+ callSession.creationTime = new Date();
9900
+ this._updateCallSession(callSession);
9857
9901
 
9858
9902
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9859
9903
 
@@ -10132,6 +10176,9 @@ class WebRTCPhone extends Emitter {
10132
10176
  callSession);
10133
10177
  }
10134
10178
 
10179
+ callSession.creationTime = new Date();
10180
+ this._updateCallSession(callSession);
10181
+
10135
10182
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10136
10183
  });
10137
10184
 
@@ -10171,6 +10218,15 @@ class WebRTCPhone extends Emitter {
10171
10218
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10172
10219
  });
10173
10220
 
10221
+ this.client.on(this.client.REJECTED, session => {
10222
+ logger$7.info('WebRTC call rejected', session.id);
10223
+ const callSession = this._createCallSession(session);
10224
+ callSession.endTime = new Date();
10225
+ this._updateCallSession(callSession);
10226
+
10227
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10228
+ });
10229
+
10174
10230
  this.client.on(this.client.UNREGISTERED, () => {
10175
10231
  logger$7.info('WebRTC unregistered');
10176
10232
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -10383,6 +10439,7 @@ class WebRTCPhone extends Emitter {
10383
10439
  const number = identity ? identity.uri._normal.user : null;
10384
10440
  const { state } = sipSession || {};
10385
10441
  const sessionId = this.getSipSessionId(sipSession);
10442
+ fromSession = fromSession || this.callSessions[sessionId];
10386
10443
 
10387
10444
  const callSession = new CallSession({
10388
10445
  callId: fromSession && fromSession.callId,
@@ -10390,6 +10447,9 @@ class WebRTCPhone extends Emitter {
10390
10447
  sipStatus: state,
10391
10448
  displayName: identity ? identity.displayName || number : number,
10392
10449
  startTime: fromSession ? fromSession.startTime : new Date(),
10450
+ creationTime: fromSession ? fromSession.creationTime : null,
10451
+ answerTime: fromSession ? fromSession.answerTime : null,
10452
+ endTime: fromSession ? fromSession.endTime : null,
10393
10453
  answered: state === sessionState.SessionState.Established,
10394
10454
  paused: this.client.isCallHeld(sipSession),
10395
10455
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10400,6 +10460,7 @@ class WebRTCPhone extends Emitter {
10400
10460
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10401
10461
  recording: fromSession ? fromSession.isRecording() : false,
10402
10462
  recordingPaused: false, // @TODO
10463
+ sipSession,
10403
10464
  ...extra,
10404
10465
  });
10405
10466
 
@@ -10428,6 +10489,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10428
10489
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10429
10490
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10430
10491
  ON_CALL_FAILED: ON_CALL_FAILED,
10492
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10431
10493
  ON_CALL_ENDED: ON_CALL_ENDED,
10432
10494
  ON_CALL_ENDING: ON_CALL_ENDING,
10433
10495
  ON_MESSAGE: ON_MESSAGE,
@@ -10457,6 +10519,14 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10457
10519
  'default': WebRTCPhone
10458
10520
  });
10459
10521
 
10522
+ /* */
10523
+ class SFUNotAvailableError extends Error {
10524
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10525
+ super(message);
10526
+ this.name = 'SFUNotAvailableError';
10527
+ }
10528
+ }
10529
+
10460
10530
  //
10461
10531
 
10462
10532
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10841,7 +10911,7 @@ class Phone extends Emitter {
10841
10911
 
10842
10912
  checkSfu() {
10843
10913
  if (!this.hasSfu()) {
10844
- throw new Error('Sorry your user is not configured to support video conference');
10914
+ throw new SFUNotAvailableError();
10845
10915
  }
10846
10916
  }
10847
10917
 
@@ -13738,6 +13808,7 @@ const Wazo = {
13738
13808
  InvalidSubscription,
13739
13809
  InvalidAuthorization,
13740
13810
  CanceledCallError,
13811
+ SFUNotAvailableError,
13741
13812
  };
13742
13813
 
13743
13814
  if (window) {
@@ -5358,6 +5358,7 @@ const MAX_REGISTER_TRIES = 10;
5358
5358
 
5359
5359
 
5360
5360
 
5361
+
5361
5362
 
5362
5363
 
5363
5364
 
@@ -6974,6 +6975,13 @@ class WebRTCClient extends Emitter {
6974
6975
  }
6975
6976
 
6976
6977
  _createWebRTCConfiguration(configOverrides = {}) {
6978
+ let { host } = this.config;
6979
+ let port = this.config.port || 443;
6980
+
6981
+ if (this.config.websocketSip) {
6982
+ [host, port = 443] = this.config.websocketSip.split(':');
6983
+ }
6984
+
6977
6985
  const config = {
6978
6986
  authorizationUsername: this.config.authorizationUser,
6979
6987
  authorizationPassword: this.config.password,
@@ -7009,7 +7017,7 @@ class WebRTCClient extends Emitter {
7009
7017
  },
7010
7018
  transportOptions: {
7011
7019
  traceSip: configOverrides.traceSip || false,
7012
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7020
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7013
7021
  },
7014
7022
  sessionDescriptionHandlerFactoryOptions: {
7015
7023
  modifiers: [replaceLocalIpModifier],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazo/sdk",
3
- "version": "0.37.27",
3
+ "version": "0.37.31",
4
4
  "description": "Wazo's JavaScript Software Development Kit.",
5
5
  "main": "dist/wazo-sdk.js",
6
6
  "author": "Wazo (http://wazo.io)",