@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
@@ -5344,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5344
5344
 
5345
5345
 
5346
5346
 
5347
+
5347
5348
 
5348
5349
 
5349
5350
 
@@ -6960,6 +6961,13 @@ class WebRTCClient extends Emitter {
6960
6961
  }
6961
6962
 
6962
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6963
6971
  const config = {
6964
6972
  authorizationUsername: this.config.authorizationUser,
6965
6973
  authorizationPassword: this.config.password,
@@ -6995,7 +7003,7 @@ class WebRTCClient extends Emitter {
6995
7003
  },
6996
7004
  transportOptions: {
6997
7005
  traceSip: configOverrides.traceSip || false,
6998
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6999
7007
  },
7000
7008
  sessionDescriptionHandlerFactoryOptions: {
7001
7009
  modifiers: [replaceLocalIpModifier],
@@ -5929,6 +5929,7 @@ const MAX_REGISTER_TRIES = 10;
5929
5929
 
5930
5930
 
5931
5931
 
5932
+
5932
5933
 
5933
5934
 
5934
5935
 
@@ -7545,6 +7546,13 @@ class WebRTCClient extends Emitter {
7545
7546
  }
7546
7547
 
7547
7548
  _createWebRTCConfiguration(configOverrides = {}) {
7549
+ let { host } = this.config;
7550
+ let port = this.config.port || 443;
7551
+
7552
+ if (this.config.websocketSip) {
7553
+ [host, port = 443] = this.config.websocketSip.split(':');
7554
+ }
7555
+
7548
7556
  const config = {
7549
7557
  authorizationUsername: this.config.authorizationUser,
7550
7558
  authorizationPassword: this.config.password,
@@ -7580,7 +7588,7 @@ class WebRTCClient extends Emitter {
7580
7588
  },
7581
7589
  transportOptions: {
7582
7590
  traceSip: configOverrides.traceSip || false,
7583
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7591
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7584
7592
  },
7585
7593
  sessionDescriptionHandlerFactoryOptions: {
7586
7594
  modifiers: [replaceLocalIpModifier],
@@ -5929,6 +5929,7 @@ const MAX_REGISTER_TRIES = 10;
5929
5929
 
5930
5930
 
5931
5931
 
5932
+
5932
5933
 
5933
5934
 
5934
5935
 
@@ -7545,6 +7546,13 @@ class WebRTCClient extends Emitter {
7545
7546
  }
7546
7547
 
7547
7548
  _createWebRTCConfiguration(configOverrides = {}) {
7549
+ let { host } = this.config;
7550
+ let port = this.config.port || 443;
7551
+
7552
+ if (this.config.websocketSip) {
7553
+ [host, port = 443] = this.config.websocketSip.split(':');
7554
+ }
7555
+
7548
7556
  const config = {
7549
7557
  authorizationUsername: this.config.authorizationUser,
7550
7558
  authorizationPassword: this.config.password,
@@ -7580,7 +7588,7 @@ class WebRTCClient extends Emitter {
7580
7588
  },
7581
7589
  transportOptions: {
7582
7590
  traceSip: configOverrides.traceSip || false,
7583
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7591
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
7584
7592
  },
7585
7593
  sessionDescriptionHandlerFactoryOptions: {
7586
7594
  modifiers: [replaceLocalIpModifier],
@@ -5344,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5344
5344
 
5345
5345
 
5346
5346
 
5347
+
5347
5348
 
5348
5349
 
5349
5350
 
@@ -6960,6 +6961,13 @@ class WebRTCClient extends Emitter {
6960
6961
  }
6961
6962
 
6962
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6963
6971
  const config = {
6964
6972
  authorizationUsername: this.config.authorizationUser,
6965
6973
  authorizationPassword: this.config.password,
@@ -6995,7 +7003,7 @@ class WebRTCClient extends Emitter {
6995
7003
  },
6996
7004
  transportOptions: {
6997
7005
  traceSip: configOverrides.traceSip || false,
6998
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6999
7007
  },
7000
7008
  sessionDescriptionHandlerFactoryOptions: {
7001
7009
  modifiers: [replaceLocalIpModifier],
@@ -5344,6 +5344,7 @@ const MAX_REGISTER_TRIES = 10;
5344
5344
 
5345
5345
 
5346
5346
 
5347
+
5347
5348
 
5348
5349
 
5349
5350
 
@@ -6960,6 +6961,13 @@ class WebRTCClient extends Emitter {
6960
6961
  }
6961
6962
 
6962
6963
  _createWebRTCConfiguration(configOverrides = {}) {
6964
+ let { host } = this.config;
6965
+ let port = this.config.port || 443;
6966
+
6967
+ if (this.config.websocketSip) {
6968
+ [host, port = 443] = this.config.websocketSip.split(':');
6969
+ }
6970
+
6963
6971
  const config = {
6964
6972
  authorizationUsername: this.config.authorizationUser,
6965
6973
  authorizationPassword: this.config.password,
@@ -6995,7 +7003,7 @@ class WebRTCClient extends Emitter {
6995
7003
  },
6996
7004
  transportOptions: {
6997
7005
  traceSip: configOverrides.traceSip || false,
6998
- wsServers: `wss://${this.config.host}:${this.config.port || 443}/api/asterisk/ws`,
7006
+ wsServers: `wss://${host}:${port}/api/asterisk/ws`,
6999
7007
  },
7000
7008
  sessionDescriptionHandlerFactoryOptions: {
7001
7009
  modifiers: [replaceLocalIpModifier],
@@ -32,13 +32,16 @@ var updateFrom = (instance , from ) => {
32
32
 
33
33
 
34
34
 
35
+
35
36
 
36
37
 
37
38
 
38
39
 
39
40
 
41
+
40
42
 
41
43
 
44
+
42
45
 
43
46
 
44
47
 
@@ -55,6 +58,7 @@ var updateFrom = (instance , from ) => {
55
58
 
56
59
 
57
60
 
61
+
58
62
 
59
63
 
60
64
  class CallSession {
@@ -74,10 +78,14 @@ class CallSession {
74
78
 
75
79
 
76
80
 
77
-
81
+
82
+
83
+ // = creationTime
78
84
 
79
85
 
80
86
 
87
+
88
+
81
89
 
82
90
 
83
91
 
@@ -113,6 +121,8 @@ class CallSession {
113
121
 
114
122
 
115
123
 
124
+
125
+
116
126
 
117
127
  constructor({
118
128
  answered,
@@ -126,6 +136,8 @@ class CallSession {
126
136
  paused,
127
137
  ringing,
128
138
  startTime,
139
+ creationTime,
140
+ endTime,
129
141
  cameraEnabled,
130
142
  dialedExtension,
131
143
  sipCallId,
@@ -138,12 +150,16 @@ class CallSession {
138
150
  recording,
139
151
  recordingPaused,
140
152
  videoRemotelyDowngraded,
153
+ sipSession,
154
+ answerTime,
141
155
  } ) {
142
156
  this.callId = callId;
143
157
  this.sipCallId = sipCallId;
144
158
  this.displayName = displayName;
145
159
  this.number = number;
160
+ this.creationTime = creationTime;
146
161
  this.startTime = startTime;
162
+ this.endTime = endTime;
147
163
  this.isCaller = isCaller;
148
164
  this.answered = answered;
149
165
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +178,8 @@ class CallSession {
162
178
  this.recording = recording || false;
163
179
  this.recordingPaused = recordingPaused || false;
164
180
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
181
+ this.sipSession = sipSession;
182
+ this.answerTime = answerTime || this.answerTime;
165
183
 
166
184
  // Useful to compare instead of instanceof with minified code
167
185
  this.type = 'CallSession';
@@ -192,7 +210,7 @@ class CallSession {
192
210
  }
193
211
 
194
212
  answer() {
195
- this.answered = true;
213
+ this.answerTime = new Date();
196
214
  }
197
215
 
198
216
  systemAnswer() {
@@ -348,6 +366,15 @@ class CallSession {
348
366
  return newFrom(callSession, CallSession);
349
367
  }
350
368
 
369
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
370
+ set answered(value ) {
371
+ this.answerTime = value ? this.answerTime || new Date() : null;
372
+ }
373
+
374
+ get answered() {
375
+ return !!this.answerTime;
376
+ }
377
+
351
378
  static parseCall(call ) {
352
379
  return new CallSession({
353
380
  callId: call.id,
@@ -1706,13 +1706,16 @@ var updateFrom = (instance , from ) => {
1706
1706
 
1707
1707
 
1708
1708
 
1709
+
1709
1710
 
1710
1711
 
1711
1712
 
1712
1713
 
1713
1714
 
1715
+
1714
1716
 
1715
1717
 
1718
+
1716
1719
 
1717
1720
 
1718
1721
 
@@ -1729,6 +1732,7 @@ var updateFrom = (instance , from ) => {
1729
1732
 
1730
1733
 
1731
1734
 
1735
+
1732
1736
 
1733
1737
 
1734
1738
  class CallSession {
@@ -1748,10 +1752,14 @@ class CallSession {
1748
1752
 
1749
1753
 
1750
1754
 
1751
-
1755
+
1756
+
1757
+ // = creationTime
1752
1758
 
1753
1759
 
1754
1760
 
1761
+
1762
+
1755
1763
 
1756
1764
 
1757
1765
 
@@ -1787,6 +1795,8 @@ class CallSession {
1787
1795
 
1788
1796
 
1789
1797
 
1798
+
1799
+
1790
1800
 
1791
1801
  constructor({
1792
1802
  answered,
@@ -1800,6 +1810,8 @@ class CallSession {
1800
1810
  paused,
1801
1811
  ringing,
1802
1812
  startTime,
1813
+ creationTime,
1814
+ endTime,
1803
1815
  cameraEnabled,
1804
1816
  dialedExtension,
1805
1817
  sipCallId,
@@ -1812,12 +1824,16 @@ class CallSession {
1812
1824
  recording,
1813
1825
  recordingPaused,
1814
1826
  videoRemotelyDowngraded,
1827
+ sipSession,
1828
+ answerTime,
1815
1829
  } ) {
1816
1830
  this.callId = callId;
1817
1831
  this.sipCallId = sipCallId;
1818
1832
  this.displayName = displayName;
1819
1833
  this.number = number;
1834
+ this.creationTime = creationTime;
1820
1835
  this.startTime = startTime;
1836
+ this.endTime = endTime;
1821
1837
  this.isCaller = isCaller;
1822
1838
  this.answered = answered;
1823
1839
  this.answeredBySystem = answeredBySystem;
@@ -1836,6 +1852,8 @@ class CallSession {
1836
1852
  this.recording = recording || false;
1837
1853
  this.recordingPaused = recordingPaused || false;
1838
1854
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
1855
+ this.sipSession = sipSession;
1856
+ this.answerTime = answerTime || this.answerTime;
1839
1857
 
1840
1858
  // Useful to compare instead of instanceof with minified code
1841
1859
  this.type = 'CallSession';
@@ -1866,7 +1884,7 @@ class CallSession {
1866
1884
  }
1867
1885
 
1868
1886
  answer() {
1869
- this.answered = true;
1887
+ this.answerTime = new Date();
1870
1888
  }
1871
1889
 
1872
1890
  systemAnswer() {
@@ -2022,6 +2040,15 @@ class CallSession {
2022
2040
  return newFrom(callSession, CallSession);
2023
2041
  }
2024
2042
 
2043
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
2044
+ set answered(value ) {
2045
+ this.answerTime = value ? this.answerTime || new Date() : null;
2046
+ }
2047
+
2048
+ get answered() {
2049
+ return !!this.answerTime;
2050
+ }
2051
+
2025
2052
  static parseCall(call ) {
2026
2053
  return new CallSession({
2027
2054
  callId: call.id,
@@ -54,13 +54,16 @@ var updateFrom = (instance , from ) => {
54
54
 
55
55
 
56
56
 
57
+
57
58
 
58
59
 
59
60
 
60
61
 
61
62
 
63
+
62
64
 
63
65
 
66
+
64
67
 
65
68
 
66
69
 
@@ -77,6 +80,7 @@ var updateFrom = (instance , from ) => {
77
80
 
78
81
 
79
82
 
83
+
80
84
 
81
85
 
82
86
  class CallSession {
@@ -96,10 +100,14 @@ class CallSession {
96
100
 
97
101
 
98
102
 
99
-
103
+
104
+
105
+ // = creationTime
100
106
 
101
107
 
102
108
 
109
+
110
+
103
111
 
104
112
 
105
113
 
@@ -135,6 +143,8 @@ class CallSession {
135
143
 
136
144
 
137
145
 
146
+
147
+
138
148
 
139
149
  constructor({
140
150
  answered,
@@ -148,6 +158,8 @@ class CallSession {
148
158
  paused,
149
159
  ringing,
150
160
  startTime,
161
+ creationTime,
162
+ endTime,
151
163
  cameraEnabled,
152
164
  dialedExtension,
153
165
  sipCallId,
@@ -160,12 +172,16 @@ class CallSession {
160
172
  recording,
161
173
  recordingPaused,
162
174
  videoRemotelyDowngraded,
175
+ sipSession,
176
+ answerTime,
163
177
  } ) {
164
178
  this.callId = callId;
165
179
  this.sipCallId = sipCallId;
166
180
  this.displayName = displayName;
167
181
  this.number = number;
182
+ this.creationTime = creationTime;
168
183
  this.startTime = startTime;
184
+ this.endTime = endTime;
169
185
  this.isCaller = isCaller;
170
186
  this.answered = answered;
171
187
  this.answeredBySystem = answeredBySystem;
@@ -184,6 +200,8 @@ class CallSession {
184
200
  this.recording = recording || false;
185
201
  this.recordingPaused = recordingPaused || false;
186
202
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
203
+ this.sipSession = sipSession;
204
+ this.answerTime = answerTime || this.answerTime;
187
205
 
188
206
  // Useful to compare instead of instanceof with minified code
189
207
  this.type = 'CallSession';
@@ -214,7 +232,7 @@ class CallSession {
214
232
  }
215
233
 
216
234
  answer() {
217
- this.answered = true;
235
+ this.answerTime = new Date();
218
236
  }
219
237
 
220
238
  systemAnswer() {
@@ -370,6 +388,15 @@ class CallSession {
370
388
  return newFrom(callSession, CallSession);
371
389
  }
372
390
 
391
+ // Retro-compatibility: `answered` was a boolean before. We can reproduce the behaviour with a getter/setter
392
+ set answered(value ) {
393
+ this.answerTime = value ? this.answerTime || new Date() : null;
394
+ }
395
+
396
+ get answered() {
397
+ return !!this.answerTime;
398
+ }
399
+
373
400
  static parseCall(call ) {
374
401
  return new CallSession({
375
402
  callId: call.id,
@@ -878,6 +905,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
878
905
  const ON_CAMERA_RESUMED = 'onCameraResumed';
879
906
  const ON_CALL_CANCELED = 'onCallCanceled';
880
907
  const ON_CALL_FAILED = 'onCallFailed';
908
+ const ON_CALL_REJECTED = 'onCallRejected';
881
909
  const ON_CALL_ENDED = 'onCallEnded';
882
910
  const ON_CALL_ENDING = 'onCallEnding';
883
911
  const ON_MESSAGE = 'onMessage';
@@ -922,6 +950,7 @@ const events = [
922
950
  ON_CAMERA_DISABLED,
923
951
  ON_CALL_FAILED,
924
952
  ON_CALL_ENDED,
953
+ ON_CALL_REJECTED,
925
954
  ON_MESSAGE,
926
955
  ON_REINVITE,
927
956
  ON_TRACK,
@@ -1278,6 +1307,7 @@ class WebRTCPhone extends Emitter {
1278
1307
 
1279
1308
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
1280
1309
  const callSession = this._createCallSession(sipSession);
1310
+ callSession.endTime = new Date();
1281
1311
  const wasCurrentSession = this._onCallTerminated(sipSession);
1282
1312
 
1283
1313
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -1473,6 +1503,8 @@ class WebRTCPhone extends Emitter {
1473
1503
  this.removeIncomingSessions(sipSessionId);
1474
1504
  }
1475
1505
 
1506
+ callSession.answerTime = new Date();
1507
+ this._updateCallSession(callSession);
1476
1508
  this.eventEmitter.emit(ON_CALL_ACCEPTED, callSession, cameraEnabled);
1477
1509
 
1478
1510
  return callSession;
@@ -1688,6 +1720,8 @@ class WebRTCPhone extends Emitter {
1688
1720
  }
1689
1721
 
1690
1722
  this.shouldSendReinvite = false;
1723
+ callSession.answerTime = new Date();
1724
+ this._updateCallSession(callSession);
1691
1725
  this.acceptedSessions[callSession.getId()] = true;
1692
1726
 
1693
1727
  this.eventEmitter.emit(ON_CALL_ANSWERED, callSession);
@@ -1787,7 +1821,7 @@ class WebRTCPhone extends Emitter {
1787
1821
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
1788
1822
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
1789
1823
  logger.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
1790
- this.holdSipSession(this.currentSipSession, callSession);
1824
+ this.holdSipSession(this.currentSipSession, this.currentCallSession);
1791
1825
  }
1792
1826
 
1793
1827
  const promise = this.unholdSipSession(sipSession, callSession, withEvent, isConference);
@@ -1997,6 +2031,8 @@ class WebRTCPhone extends Emitter {
1997
2031
  return Promise.resolve(null);
1998
2032
  }
1999
2033
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
2034
+ callSession.creationTime = new Date();
2035
+ this._updateCallSession(callSession);
2000
2036
 
2001
2037
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
2002
2038
 
@@ -2275,6 +2311,9 @@ class WebRTCPhone extends Emitter {
2275
2311
  callSession);
2276
2312
  }
2277
2313
 
2314
+ callSession.creationTime = new Date();
2315
+ this._updateCallSession(callSession);
2316
+
2278
2317
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
2279
2318
  });
2280
2319
 
@@ -2314,6 +2353,15 @@ class WebRTCPhone extends Emitter {
2314
2353
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2315
2354
  });
2316
2355
 
2356
+ this.client.on(this.client.REJECTED, session => {
2357
+ logger.info('WebRTC call rejected', session.id);
2358
+ const callSession = this._createCallSession(session);
2359
+ callSession.endTime = new Date();
2360
+ this._updateCallSession(callSession);
2361
+
2362
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
2363
+ });
2364
+
2317
2365
  this.client.on(this.client.UNREGISTERED, () => {
2318
2366
  logger.info('WebRTC unregistered');
2319
2367
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -2526,6 +2574,7 @@ class WebRTCPhone extends Emitter {
2526
2574
  const number = identity ? identity.uri._normal.user : null;
2527
2575
  const { state } = sipSession || {};
2528
2576
  const sessionId = this.getSipSessionId(sipSession);
2577
+ fromSession = fromSession || this.callSessions[sessionId];
2529
2578
 
2530
2579
  const callSession = new CallSession({
2531
2580
  callId: fromSession && fromSession.callId,
@@ -2533,6 +2582,9 @@ class WebRTCPhone extends Emitter {
2533
2582
  sipStatus: state,
2534
2583
  displayName: identity ? identity.displayName || number : number,
2535
2584
  startTime: fromSession ? fromSession.startTime : new Date(),
2585
+ creationTime: fromSession ? fromSession.creationTime : null,
2586
+ answerTime: fromSession ? fromSession.answerTime : null,
2587
+ endTime: fromSession ? fromSession.endTime : null,
2536
2588
  answered: state === SessionState.Established,
2537
2589
  paused: this.client.isCallHeld(sipSession),
2538
2590
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -2543,6 +2595,7 @@ class WebRTCPhone extends Emitter {
2543
2595
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
2544
2596
  recording: fromSession ? fromSession.isRecording() : false,
2545
2597
  recordingPaused: false, // @TODO
2598
+ sipSession,
2546
2599
  ...extra,
2547
2600
  });
2548
2601
 
@@ -2553,4 +2606,4 @@ class WebRTCPhone extends Emitter {
2553
2606
  }
2554
2607
 
2555
2608
  export default WebRTCPhone;
2556
- export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
2609
+ export { MESSAGE_TYPE_CHAT, MESSAGE_TYPE_SIGNAL, ON_AUDIO_STREAM, ON_CALL_ACCEPTED, ON_CALL_ANSWERED, ON_CALL_CANCELED, ON_CALL_ENDED, ON_CALL_ENDING, ON_CALL_ERROR, ON_CALL_FAILED, ON_CALL_HELD, ON_CALL_INCOMING, ON_CALL_MUTED, ON_CALL_OUTGOING, ON_CALL_REJECTED, ON_CALL_RESUMED, ON_CALL_UNHELD, ON_CALL_UNMUTED, ON_CAMERA_DISABLED, ON_CAMERA_RESUMED, ON_CHAT, ON_DISCONNECTED, ON_MESSAGE, ON_MESSAGE_TRACK_UPDATED, ON_NETWORK_STATS, ON_PLAY_HANGUP_SOUND, ON_PLAY_INBOUND_CALL_SIGNAL_SOUND, ON_PLAY_PROGRESS_SOUND, ON_PLAY_RING_SOUND, ON_PROGRESS, ON_REGISTERED, ON_REINVITE, ON_REMOVE_STREAM, ON_SHARE_SCREEN_ENDED, ON_SHARE_SCREEN_ENDING, ON_SHARE_SCREEN_STARTED, ON_SIGNAL, ON_TERMINATE_SOUND, ON_TRACK, ON_UNREGISTERED, ON_USER_AGENT, ON_VIDEO_INPUT_CHANGE, ON_VIDEO_STREAM, events };
@@ -0,0 +1,9 @@
1
+ /* */
2
+ class SFUNotAvailableError extends Error {
3
+ constructor(message = 'Sorry your user is not configured to support video conference') {
4
+ super(message);
5
+ this.name = 'SFUNotAvailableError';
6
+ }
7
+ }
8
+
9
+ export default SFUNotAvailableError;