@wazo/sdk 0.37.29 → 0.37.33

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 (81) hide show
  1. package/README.md +2 -1
  2. package/dist/wazo-sdk.js +4 -4
  3. package/esm/__tests__/api-client.test.js +30 -0
  4. package/esm/__tests__/web-rtc-client.test.js +65 -6
  5. package/esm/api/calld.js +30 -0
  6. package/esm/api-client.js +30 -0
  7. package/esm/checker/Checker.js +65 -6
  8. package/esm/checker/checks/aor.js +30 -0
  9. package/esm/checker/checks/api.js +30 -0
  10. package/esm/checker/checks/index.js +65 -6
  11. package/esm/checker/checks/webrtc-transport.js +65 -6
  12. package/esm/checker/checks/webrtc.js +65 -6
  13. package/esm/domain/AdHocAPIConference.js +30 -0
  14. package/esm/domain/CallSession.js +9 -1
  15. package/esm/domain/Features.js +30 -0
  16. package/esm/domain/MeetingStatus.js +29 -0
  17. package/esm/domain/Phone/CTIPhone.js +39 -1
  18. package/esm/domain/Phone/WebRTCPhone.js +20 -4
  19. package/esm/domain/__tests__/CallSession.test.js +41 -5
  20. package/esm/domain/__tests__/IndirectTransfer.test.js +9 -1
  21. package/esm/domain/__tests__/Room.test.js +9 -1
  22. package/esm/index.js +85 -10
  23. package/esm/service/CallApi.js +30 -0
  24. package/esm/service/getApiClient.js +30 -0
  25. package/esm/simple/Auth.js +85 -10
  26. package/esm/simple/Configuration.js +85 -10
  27. package/esm/simple/Directory.js +30 -0
  28. package/esm/simple/Phone.js +85 -10
  29. package/esm/simple/index.js +85 -10
  30. package/esm/simple/room/LocalParticipant.js +85 -10
  31. package/esm/simple/room/Participant.js +85 -10
  32. package/esm/simple/room/RemoteParticipant.js +85 -10
  33. package/esm/simple/room/Room.js +85 -10
  34. package/esm/simple/room/SipRoom.js +85 -10
  35. package/esm/simple/room/Stream.js +85 -10
  36. package/esm/simple/room/__tests__/RemoteParticipant.test.js +85 -10
  37. package/esm/simple/utils.js +85 -10
  38. package/esm/web-rtc-client.js +65 -6
  39. package/lib/__tests__/api-client.test.js +30 -0
  40. package/lib/__tests__/web-rtc-client.test.js +65 -6
  41. package/lib/api/calld.js +30 -0
  42. package/lib/api-client.js +30 -0
  43. package/lib/checker/Checker.js +65 -6
  44. package/lib/checker/checks/aor.js +30 -0
  45. package/lib/checker/checks/api.js +30 -0
  46. package/lib/checker/checks/index.js +65 -6
  47. package/lib/checker/checks/webrtc-transport.js +65 -6
  48. package/lib/checker/checks/webrtc.js +65 -6
  49. package/lib/domain/AdHocAPIConference.js +30 -0
  50. package/lib/domain/CallSession.js +9 -1
  51. package/lib/domain/Features.js +30 -0
  52. package/lib/domain/MeetingStatus.js +31 -0
  53. package/lib/domain/Phone/CTIPhone.js +39 -1
  54. package/lib/domain/Phone/WebRTCPhone.js +20 -4
  55. package/lib/domain/__tests__/CallSession.test.js +41 -5
  56. package/lib/domain/__tests__/IndirectTransfer.test.js +9 -1
  57. package/lib/domain/__tests__/Room.test.js +9 -1
  58. package/lib/index.js +85 -10
  59. package/lib/service/CallApi.js +30 -0
  60. package/lib/service/getApiClient.js +30 -0
  61. package/lib/simple/Auth.js +85 -10
  62. package/lib/simple/Configuration.js +85 -10
  63. package/lib/simple/Directory.js +30 -0
  64. package/lib/simple/Phone.js +85 -10
  65. package/lib/simple/index.js +85 -10
  66. package/lib/simple/room/LocalParticipant.js +85 -10
  67. package/lib/simple/room/Participant.js +85 -10
  68. package/lib/simple/room/RemoteParticipant.js +85 -10
  69. package/lib/simple/room/Room.js +85 -10
  70. package/lib/simple/room/SipRoom.js +85 -10
  71. package/lib/simple/room/Stream.js +85 -10
  72. package/lib/simple/room/__tests__/RemoteParticipant.test.js +85 -10
  73. package/lib/simple/utils.js +85 -10
  74. package/lib/web-rtc-client.js +65 -6
  75. package/package.json +1 -1
  76. package/src/api/calld.js +3 -0
  77. package/src/domain/CallSession.js +9 -1
  78. package/src/domain/MeetingStatus.js +27 -0
  79. package/src/domain/Phone/WebRTCPhone.js +11 -3
  80. package/src/domain/__tests__/CallSession.test.js +32 -4
  81. package/src/web-rtc-client.js +35 -6
@@ -4022,6 +4022,34 @@ class IndirectTransfer {
4022
4022
  }
4023
4023
  }
4024
4024
 
4025
+ //
4026
+
4027
+
4028
+
4029
+
4030
+
4031
+ class MeetingStatus {
4032
+
4033
+
4034
+
4035
+
4036
+ constructor({
4037
+ full,
4038
+ } = {}) {
4039
+ this.full = full;
4040
+
4041
+ // Useful to compare instead of instanceof with minified code
4042
+ this.type = 'MeetingStatus';
4043
+ }
4044
+
4045
+ static parse(plain ) {
4046
+ return new MeetingStatus({
4047
+ full: plain.full,
4048
+ });
4049
+ }
4050
+
4051
+ }
4052
+
4025
4053
  /* */
4026
4054
 
4027
4055
 
@@ -4216,6 +4244,8 @@ var calldMethods = (client , baseUrl ) => ({
4216
4244
  client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
4217
4245
  ApiRequester.successResponseParser),
4218
4246
 
4247
+ guestGetMeetingStatus: (meetingUuid ) =>
4248
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
4219
4249
  });
4220
4250
 
4221
4251
  //
@@ -4024,6 +4024,34 @@ var chatdMethods = (client , baseUrl ) => ({
4024
4024
  client.get(`${baseUrl}/users/me/rooms/messages`, options),
4025
4025
  });
4026
4026
 
4027
+ //
4028
+
4029
+
4030
+
4031
+
4032
+
4033
+ class MeetingStatus {
4034
+
4035
+
4036
+
4037
+
4038
+ constructor({
4039
+ full,
4040
+ } = {}) {
4041
+ this.full = full;
4042
+
4043
+ // Useful to compare instead of instanceof with minified code
4044
+ this.type = 'MeetingStatus';
4045
+ }
4046
+
4047
+ static parse(plain ) {
4048
+ return new MeetingStatus({
4049
+ full: plain.full,
4050
+ });
4051
+ }
4052
+
4053
+ }
4054
+
4027
4055
  /* */
4028
4056
 
4029
4057
 
@@ -4218,6 +4246,8 @@ var calldMethods = (client , baseUrl ) => ({
4218
4246
  client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
4219
4247
  ApiRequester.successResponseParser),
4220
4248
 
4249
+ guestGetMeetingStatus: (meetingUuid ) =>
4250
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
4221
4251
  });
4222
4252
 
4223
4253
  //
@@ -3596,13 +3596,21 @@ class CallSession {
3596
3596
 
3597
3597
  // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3598
3598
  set answered(value ) {
3599
- this.answerTime = value ? new Date() : null;
3599
+ this.answerTime = value ? this.answerTime || new Date() : null;
3600
3600
  }
3601
3601
 
3602
3602
  get answered() {
3603
3603
  return !!this.answerTime;
3604
3604
  }
3605
3605
 
3606
+ toJSON() {
3607
+ const jsonObj = { ...this };
3608
+ // $FlowFixMe
3609
+ jsonObj.answered = this.answered;
3610
+
3611
+ return jsonObj;
3612
+ }
3613
+
3606
3614
  static parseCall(call ) {
3607
3615
  return new CallSession({
3608
3616
  callId: call.id,
@@ -4854,6 +4862,34 @@ var chatdMethods = (client , baseUrl ) => ({
4854
4862
  client.get(`${baseUrl}/users/me/rooms/messages`, options),
4855
4863
  });
4856
4864
 
4865
+ //
4866
+
4867
+
4868
+
4869
+
4870
+
4871
+ class MeetingStatus {
4872
+
4873
+
4874
+
4875
+
4876
+ constructor({
4877
+ full,
4878
+ } = {}) {
4879
+ this.full = full;
4880
+
4881
+ // Useful to compare instead of instanceof with minified code
4882
+ this.type = 'MeetingStatus';
4883
+ }
4884
+
4885
+ static parse(plain ) {
4886
+ return new MeetingStatus({
4887
+ full: plain.full,
4888
+ });
4889
+ }
4890
+
4891
+ }
4892
+
4857
4893
  /* */
4858
4894
 
4859
4895
 
@@ -5048,6 +5084,8 @@ var calldMethods = (client , baseUrl ) => ({
5048
5084
  client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
5049
5085
  ApiRequester.successResponseParser),
5050
5086
 
5087
+ guestGetMeetingStatus: (meetingUuid ) =>
5088
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
5051
5089
  });
5052
5090
 
5053
5091
  //
@@ -6385,6 +6423,7 @@ const MAX_REGISTER_TRIES = 10;
6385
6423
 
6386
6424
 
6387
6425
 
6426
+
6388
6427
 
6389
6428
 
6390
6429
 
@@ -6426,6 +6465,7 @@ class WebRTCClient extends Emitter {
6426
6465
 
6427
6466
 
6428
6467
 
6468
+
6429
6469
 
6430
6470
  // sugar
6431
6471
 
@@ -6488,6 +6528,7 @@ class WebRTCClient extends Emitter {
6488
6528
  this.conferences = {};
6489
6529
  this.networkMonitoringInterval = {};
6490
6530
  this.sessionNetworkStats = {};
6531
+ this.forceClosed = false;
6491
6532
 
6492
6533
  this._boundOnHeartbeat = this._onHeartbeat.bind(this);
6493
6534
  this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
@@ -6609,6 +6650,8 @@ class WebRTCClient extends Emitter {
6609
6650
  skipRegister: this.skipRegister,
6610
6651
  };
6611
6652
 
6653
+ this.forceClosed = false;
6654
+
6612
6655
  if (this.skipRegister) {
6613
6656
  logger$9.info('sdk webrtc skip register...', logInfo);
6614
6657
  return Promise.resolve();
@@ -6633,7 +6676,15 @@ class WebRTCClient extends Emitter {
6633
6676
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6634
6677
 
6635
6678
  const onRegisterFailed = () => {
6636
- logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6679
+ logger$9.info('sdk webrtc registering failed', {
6680
+ tries,
6681
+ registerer: !!this.registerer,
6682
+ forceClosed: this.forceClosed,
6683
+ });
6684
+ if (this.forceClosed) {
6685
+ return;
6686
+ }
6687
+
6637
6688
  this.connectionPromise = null;
6638
6689
  if (this.registerer && this.registerer.waiting) {
6639
6690
  this.registerer.waitingToggle(false);
@@ -6911,8 +6962,9 @@ class WebRTCClient extends Emitter {
6911
6962
  }
6912
6963
  }
6913
6964
 
6914
- async close() {
6915
- logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6965
+ async close(force = false) {
6966
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
6967
+ this.forceClosed = force;
6916
6968
  this._cleanupMedia();
6917
6969
  this.connectionPromise = null;
6918
6970
 
@@ -6931,7 +6983,7 @@ class WebRTCClient extends Emitter {
6931
6983
  this.userAgent.delegate = null;
6932
6984
  this.userAgent.stateChange.removeAllListeners();
6933
6985
 
6934
- await this._disconnectTransport();
6986
+ await this._disconnectTransport(force);
6935
6987
 
6936
6988
  this._cleanupRegister();
6937
6989
 
@@ -8001,6 +8053,13 @@ class WebRTCClient extends Emitter {
8001
8053
  }
8002
8054
 
8003
8055
  _createWebRTCConfiguration(configOverrides = {}) {
8056
+ let { host } = this.config;
8057
+ let port = this.config.port || 443;
8058
+
8059
+ if (this.config.websocketSip) {
8060
+ [host, port = 443] = this.config.websocketSip.split(':');
8061
+ }
8062
+
8004
8063
  const config = {
8005
8064
  authorizationUsername: this.config.authorizationUser,
8006
8065
  authorizationPassword: this.config.password,
@@ -8036,7 +8095,7 @@ class WebRTCClient extends Emitter {
8036
8095
  },
8037
8096
  transportOptions: {
8038
8097
  traceSip: configOverrides.traceSip || false,
8039
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8098
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8040
8099
  },
8041
8100
  sessionDescriptionHandlerFactoryOptions: {
8042
8101
  modifiers: [replaceLocalIpModifier],
@@ -8360,7 +8419,15 @@ class WebRTCClient extends Emitter {
8360
8419
  return userAgent.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
8361
8420
  }
8362
8421
 
8363
- async _disconnectTransport() {
8422
+ async _disconnectTransport(force = false) {
8423
+ if (force) {
8424
+ // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8425
+ this.userAgent.transport.disconnectResolve = () => {};
8426
+ // eslint-disable-next-line
8427
+ this.userAgent.transport._ws.close(1000);
8428
+ return;
8429
+ }
8430
+
8364
8431
  // Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
8365
8432
  if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
8366
8433
  try {
@@ -9097,6 +9164,7 @@ class WebRTCPhone extends Emitter {
9097
9164
  }
9098
9165
 
9099
9166
  callSession.answerTime = new Date();
9167
+ this._updateCallSession(callSession);
9100
9168
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9101
9169
 
9102
9170
  return callSession;
@@ -9313,6 +9381,7 @@ class WebRTCPhone extends Emitter {
9313
9381
 
9314
9382
  this.shouldSendReinvite = false;
9315
9383
  callSession.answerTime = new Date();
9384
+ this._updateCallSession(callSession);
9316
9385
  this.acceptedSessions[callSession.getId()] = true;
9317
9386
 
9318
9387
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9412,7 +9481,7 @@ class WebRTCPhone extends Emitter {
9412
9481
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9413
9482
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9414
9483
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9415
- this.holdSipSession(this.currentSipSession, callSession);
9484
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9416
9485
  }
9417
9486
 
9418
9487
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9623,6 +9692,7 @@ class WebRTCPhone extends Emitter {
9623
9692
  }
9624
9693
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9625
9694
  callSession.creationTime = new Date();
9695
+ this._updateCallSession(callSession);
9626
9696
 
9627
9697
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9628
9698
 
@@ -9764,7 +9834,7 @@ class WebRTCPhone extends Emitter {
9764
9834
  return this.client && this.client.isConference(callSession.sipCallId);
9765
9835
  }
9766
9836
 
9767
- async close() {
9837
+ async close(force = false) {
9768
9838
  logger$8.info('WebRTC close');
9769
9839
 
9770
9840
  try {
@@ -9776,7 +9846,7 @@ class WebRTCPhone extends Emitter {
9776
9846
  logger$8.error('WebRTC close, unregister error', e);
9777
9847
  }
9778
9848
 
9779
- this.client.close();
9849
+ this.client.close(force);
9780
9850
  this.unbind();
9781
9851
 
9782
9852
  this.incomingSessions = [];
@@ -9902,6 +9972,8 @@ class WebRTCPhone extends Emitter {
9902
9972
  }
9903
9973
 
9904
9974
  callSession.creationTime = new Date();
9975
+ this._updateCallSession(callSession);
9976
+
9905
9977
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9906
9978
  });
9907
9979
 
@@ -9945,6 +10017,8 @@ class WebRTCPhone extends Emitter {
9945
10017
  logger$8.info('WebRTC call rejected', session.id);
9946
10018
  const callSession = this._createCallSession(session);
9947
10019
  callSession.endTime = new Date();
10020
+ this._updateCallSession(callSession);
10021
+
9948
10022
  this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9949
10023
  });
9950
10024
 
@@ -10169,6 +10243,7 @@ class WebRTCPhone extends Emitter {
10169
10243
  displayName: identity ? identity.displayName || number : number,
10170
10244
  startTime: fromSession ? fromSession.startTime : new Date(),
10171
10245
  creationTime: fromSession ? fromSession.creationTime : null,
10246
+ answerTime: fromSession ? fromSession.answerTime : null,
10172
10247
  endTime: fromSession ? fromSession.endTime : null,
10173
10248
  answered: state === sessionState.SessionState.Established,
10174
10249
  paused: this.client.isCallHeld(sipSession),
@@ -3594,13 +3594,21 @@ class CallSession {
3594
3594
 
3595
3595
  // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
3596
3596
  set answered(value ) {
3597
- this.answerTime = value ? new Date() : null;
3597
+ this.answerTime = value ? this.answerTime || new Date() : null;
3598
3598
  }
3599
3599
 
3600
3600
  get answered() {
3601
3601
  return !!this.answerTime;
3602
3602
  }
3603
3603
 
3604
+ toJSON() {
3605
+ const jsonObj = { ...this };
3606
+ // $FlowFixMe
3607
+ jsonObj.answered = this.answered;
3608
+
3609
+ return jsonObj;
3610
+ }
3611
+
3604
3612
  static parseCall(call ) {
3605
3613
  return new CallSession({
3606
3614
  callId: call.id,
@@ -4852,6 +4860,34 @@ var chatdMethods = (client , baseUrl ) => ({
4852
4860
  client.get(`${baseUrl}/users/me/rooms/messages`, options),
4853
4861
  });
4854
4862
 
4863
+ //
4864
+
4865
+
4866
+
4867
+
4868
+
4869
+ class MeetingStatus {
4870
+
4871
+
4872
+
4873
+
4874
+ constructor({
4875
+ full,
4876
+ } = {}) {
4877
+ this.full = full;
4878
+
4879
+ // Useful to compare instead of instanceof with minified code
4880
+ this.type = 'MeetingStatus';
4881
+ }
4882
+
4883
+ static parse(plain ) {
4884
+ return new MeetingStatus({
4885
+ full: plain.full,
4886
+ });
4887
+ }
4888
+
4889
+ }
4890
+
4855
4891
  /* */
4856
4892
 
4857
4893
 
@@ -5046,6 +5082,8 @@ var calldMethods = (client , baseUrl ) => ({
5046
5082
  client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
5047
5083
  ApiRequester.successResponseParser),
5048
5084
 
5085
+ guestGetMeetingStatus: (meetingUuid ) =>
5086
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
5049
5087
  });
5050
5088
 
5051
5089
  //
@@ -6383,6 +6421,7 @@ const MAX_REGISTER_TRIES = 10;
6383
6421
 
6384
6422
 
6385
6423
 
6424
+
6386
6425
 
6387
6426
 
6388
6427
 
@@ -6424,6 +6463,7 @@ class WebRTCClient extends Emitter {
6424
6463
 
6425
6464
 
6426
6465
 
6466
+
6427
6467
 
6428
6468
  // sugar
6429
6469
 
@@ -6486,6 +6526,7 @@ class WebRTCClient extends Emitter {
6486
6526
  this.conferences = {};
6487
6527
  this.networkMonitoringInterval = {};
6488
6528
  this.sessionNetworkStats = {};
6529
+ this.forceClosed = false;
6489
6530
 
6490
6531
  this._boundOnHeartbeat = this._onHeartbeat.bind(this);
6491
6532
  this.heartbeat = new Heartbeat(config.heartbeatDelay, config.heartbeatTimeout, config.maxHeartbeats);
@@ -6607,6 +6648,8 @@ class WebRTCClient extends Emitter {
6607
6648
  skipRegister: this.skipRegister,
6608
6649
  };
6609
6650
 
6651
+ this.forceClosed = false;
6652
+
6610
6653
  if (this.skipRegister) {
6611
6654
  logger$9.info('sdk webrtc skip register...', logInfo);
6612
6655
  return Promise.resolve();
@@ -6631,7 +6674,15 @@ class WebRTCClient extends Emitter {
6631
6674
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6632
6675
 
6633
6676
  const onRegisterFailed = () => {
6634
- logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6677
+ logger$9.info('sdk webrtc registering failed', {
6678
+ tries,
6679
+ registerer: !!this.registerer,
6680
+ forceClosed: this.forceClosed,
6681
+ });
6682
+ if (this.forceClosed) {
6683
+ return;
6684
+ }
6685
+
6635
6686
  this.connectionPromise = null;
6636
6687
  if (this.registerer && this.registerer.waiting) {
6637
6688
  this.registerer.waitingToggle(false);
@@ -6909,8 +6960,9 @@ class WebRTCClient extends Emitter {
6909
6960
  }
6910
6961
  }
6911
6962
 
6912
- async close() {
6913
- logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6963
+ async close(force = false) {
6964
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent, force });
6965
+ this.forceClosed = force;
6914
6966
  this._cleanupMedia();
6915
6967
  this.connectionPromise = null;
6916
6968
 
@@ -6929,7 +6981,7 @@ class WebRTCClient extends Emitter {
6929
6981
  this.userAgent.delegate = null;
6930
6982
  this.userAgent.stateChange.removeAllListeners();
6931
6983
 
6932
- await this._disconnectTransport();
6984
+ await this._disconnectTransport(force);
6933
6985
 
6934
6986
  this._cleanupRegister();
6935
6987
 
@@ -7999,6 +8051,13 @@ class WebRTCClient extends Emitter {
7999
8051
  }
8000
8052
 
8001
8053
  _createWebRTCConfiguration(configOverrides = {}) {
8054
+ let { host } = this.config;
8055
+ let port = this.config.port || 443;
8056
+
8057
+ if (this.config.websocketSip) {
8058
+ [host, port = 443] = this.config.websocketSip.split(':');
8059
+ }
8060
+
8002
8061
  const config = {
8003
8062
  authorizationUsername: this.config.authorizationUser,
8004
8063
  authorizationPassword: this.config.password,
@@ -8034,7 +8093,7 @@ class WebRTCClient extends Emitter {
8034
8093
  },
8035
8094
  transportOptions: {
8036
8095
  traceSip: configOverrides.traceSip || false,
8037
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
8096
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
8038
8097
  },
8039
8098
  sessionDescriptionHandlerFactoryOptions: {
8040
8099
  modifiers: [replaceLocalIpModifier],
@@ -8358,7 +8417,15 @@ class WebRTCClient extends Emitter {
8358
8417
  return userAgent.UserAgent.makeURI(`sip:${target}@${this.config.host}`);
8359
8418
  }
8360
8419
 
8361
- async _disconnectTransport() {
8420
+ async _disconnectTransport(force = false) {
8421
+ if (force) {
8422
+ // Bypass sip.js state machine that prevent to close WS with the state `Connecting`
8423
+ this.userAgent.transport.disconnectResolve = () => {};
8424
+ // eslint-disable-next-line
8425
+ this.userAgent.transport._ws.close(1000);
8426
+ return;
8427
+ }
8428
+
8362
8429
  // Check if `disconnectPromise` is not present to avoid `Disconnect promise must not be defined` errors.
8363
8430
  if (this.userAgent && this.userAgent.transport && !this.userAgent.transport.disconnectPromise) {
8364
8431
  try {
@@ -9095,6 +9162,7 @@ class WebRTCPhone extends Emitter {
9095
9162
  }
9096
9163
 
9097
9164
  callSession.answerTime = new Date();
9165
+ this._updateCallSession(callSession);
9098
9166
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
9099
9167
 
9100
9168
  return callSession;
@@ -9311,6 +9379,7 @@ class WebRTCPhone extends Emitter {
9311
9379
 
9312
9380
  this.shouldSendReinvite = false;
9313
9381
  callSession.answerTime = new Date();
9382
+ this._updateCallSession(callSession);
9314
9383
  this.acceptedSessions[callSession.getId()] = true;
9315
9384
 
9316
9385
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -9410,7 +9479,7 @@ class WebRTCPhone extends Emitter {
9410
9479
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9411
9480
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9412
9481
  logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9413
- this.holdSipSession(this.currentSipSession, callSession);
9482
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
9414
9483
  }
9415
9484
 
9416
9485
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -9621,6 +9690,7 @@ class WebRTCPhone extends Emitter {
9621
9690
  }
9622
9691
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9623
9692
  callSession.creationTime = new Date();
9693
+ this._updateCallSession(callSession);
9624
9694
 
9625
9695
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9626
9696
 
@@ -9762,7 +9832,7 @@ class WebRTCPhone extends Emitter {
9762
9832
  return this.client && this.client.isConference(callSession.sipCallId);
9763
9833
  }
9764
9834
 
9765
- async close() {
9835
+ async close(force = false) {
9766
9836
  logger$8.info('WebRTC close');
9767
9837
 
9768
9838
  try {
@@ -9774,7 +9844,7 @@ class WebRTCPhone extends Emitter {
9774
9844
  logger$8.error('WebRTC close, unregister error', e);
9775
9845
  }
9776
9846
 
9777
- this.client.close();
9847
+ this.client.close(force);
9778
9848
  this.unbind();
9779
9849
 
9780
9850
  this.incomingSessions = [];
@@ -9900,6 +9970,8 @@ class WebRTCPhone extends Emitter {
9900
9970
  }
9901
9971
 
9902
9972
  callSession.creationTime = new Date();
9973
+ this._updateCallSession(callSession);
9974
+
9903
9975
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9904
9976
  });
9905
9977
 
@@ -9943,6 +10015,8 @@ class WebRTCPhone extends Emitter {
9943
10015
  logger$8.info('WebRTC call rejected', session.id);
9944
10016
  const callSession = this._createCallSession(session);
9945
10017
  callSession.endTime = new Date();
10018
+ this._updateCallSession(callSession);
10019
+
9946
10020
  this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9947
10021
  });
9948
10022
 
@@ -10167,6 +10241,7 @@ class WebRTCPhone extends Emitter {
10167
10241
  displayName: identity ? identity.displayName || number : number,
10168
10242
  startTime: fromSession ? fromSession.startTime : new Date(),
10169
10243
  creationTime: fromSession ? fromSession.creationTime : null,
10244
+ answerTime: fromSession ? fromSession.answerTime : null,
10170
10245
  endTime: fromSession ? fromSession.endTime : null,
10171
10246
  answered: state === sessionState.SessionState.Established,
10172
10247
  paused: this.client.isCallHeld(sipSession),
@@ -4022,6 +4022,34 @@ var chatdMethods = (client , baseUrl ) => ({
4022
4022
  client.get(`${baseUrl}/users/me/rooms/messages`, options),
4023
4023
  });
4024
4024
 
4025
+ //
4026
+
4027
+
4028
+
4029
+
4030
+
4031
+ class MeetingStatus {
4032
+
4033
+
4034
+
4035
+
4036
+ constructor({
4037
+ full,
4038
+ } = {}) {
4039
+ this.full = full;
4040
+
4041
+ // Useful to compare instead of instanceof with minified code
4042
+ this.type = 'MeetingStatus';
4043
+ }
4044
+
4045
+ static parse(plain ) {
4046
+ return new MeetingStatus({
4047
+ full: plain.full,
4048
+ });
4049
+ }
4050
+
4051
+ }
4052
+
4025
4053
  /* */
4026
4054
 
4027
4055
 
@@ -4216,6 +4244,8 @@ var calldMethods = (client , baseUrl ) => ({
4216
4244
  client.put(`${baseUrl}/users/me/calls/${callId}/record/resume`, null, null,
4217
4245
  ApiRequester.successResponseParser),
4218
4246
 
4247
+ guestGetMeetingStatus: (meetingUuid ) =>
4248
+ client.get(`${baseUrl}/guests/me/meetings/${meetingUuid}/status`).then(MeetingStatus.parse),
4219
4249
  });
4220
4250
 
4221
4251
  //