@wazo/sdk 0.37.27 → 0.37.28

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 (49) hide show
  1. package/README.md +1 -1
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/domain/CallSession.js +15 -0
  4. package/esm/domain/Phone/CTIPhone.js +15 -0
  5. package/esm/domain/Phone/WebRTCPhone.js +32 -1
  6. package/esm/domain/SFUNotAvailableError.js +9 -0
  7. package/esm/domain/__tests__/CallSession.test.js +15 -0
  8. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
  9. package/esm/domain/__tests__/Room.test.js +15 -0
  10. package/esm/index.js +43 -1
  11. package/esm/simple/Auth.js +42 -1
  12. package/esm/simple/Configuration.js +42 -1
  13. package/esm/simple/Phone.js +42 -1
  14. package/esm/simple/index.js +42 -1
  15. package/esm/simple/room/LocalParticipant.js +42 -1
  16. package/esm/simple/room/Participant.js +42 -1
  17. package/esm/simple/room/RemoteParticipant.js +42 -1
  18. package/esm/simple/room/Room.js +42 -1
  19. package/esm/simple/room/SipRoom.js +42 -1
  20. package/esm/simple/room/Stream.js +42 -1
  21. package/esm/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  22. package/esm/simple/utils.js +42 -1
  23. package/lib/domain/CallSession.js +15 -0
  24. package/lib/domain/Phone/CTIPhone.js +15 -0
  25. package/lib/domain/Phone/WebRTCPhone.js +32 -0
  26. package/lib/domain/SFUNotAvailableError.js +11 -0
  27. package/lib/domain/__tests__/CallSession.test.js +15 -0
  28. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
  29. package/lib/domain/__tests__/Room.test.js +15 -0
  30. package/lib/index.js +43 -1
  31. package/lib/simple/Auth.js +42 -1
  32. package/lib/simple/Configuration.js +42 -1
  33. package/lib/simple/Phone.js +42 -1
  34. package/lib/simple/index.js +42 -1
  35. package/lib/simple/room/LocalParticipant.js +42 -1
  36. package/lib/simple/room/Participant.js +42 -1
  37. package/lib/simple/room/RemoteParticipant.js +42 -1
  38. package/lib/simple/room/Room.js +42 -1
  39. package/lib/simple/room/SipRoom.js +42 -1
  40. package/lib/simple/room/Stream.js +42 -1
  41. package/lib/simple/room/__tests__/RemoteParticipant.test.js +42 -1
  42. package/lib/simple/utils.js +42 -1
  43. package/package.json +1 -1
  44. package/src/domain/CallSession.js +16 -0
  45. package/src/domain/Phone/WebRTCPhone.js +16 -0
  46. package/src/domain/SFUNotAvailableError.js +7 -0
  47. package/src/index.js +2 -0
  48. package/src/simple/Phone.js +2 -1
  49. package/src/simple/index.js +2 -0
@@ -37,8 +37,10 @@ var updateFrom = (instance , from ) => {
37
37
 
38
38
 
39
39
 
40
+
40
41
 
41
42
 
43
+
42
44
 
43
45
 
44
46
 
@@ -55,6 +57,7 @@ var updateFrom = (instance , from ) => {
55
57
 
56
58
 
57
59
 
60
+
58
61
 
59
62
 
60
63
  class CallSession {
@@ -74,8 +77,12 @@ class CallSession {
74
77
 
75
78
 
76
79
 
80
+
81
+
77
82
 
78
83
 
84
+
85
+
79
86
 
80
87
 
81
88
 
@@ -113,6 +120,8 @@ class CallSession {
113
120
 
114
121
 
115
122
 
123
+
124
+
116
125
 
117
126
  constructor({
118
127
  answered,
@@ -126,6 +135,8 @@ class CallSession {
126
135
  paused,
127
136
  ringing,
128
137
  startTime,
138
+ creationTime,
139
+ endTime,
129
140
  cameraEnabled,
130
141
  dialedExtension,
131
142
  sipCallId,
@@ -138,12 +149,15 @@ class CallSession {
138
149
  recording,
139
150
  recordingPaused,
140
151
  videoRemotelyDowngraded,
152
+ sipSession,
141
153
  } ) {
142
154
  this.callId = callId;
143
155
  this.sipCallId = sipCallId;
144
156
  this.displayName = displayName;
145
157
  this.number = number;
158
+ this.creationTime = creationTime;
146
159
  this.startTime = startTime;
160
+ this.endTime = endTime;
147
161
  this.isCaller = isCaller;
148
162
  this.answered = answered;
149
163
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +176,7 @@ class CallSession {
162
176
  this.recording = recording || false;
163
177
  this.recordingPaused = recordingPaused || false;
164
178
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
179
+ this.sipSession = sipSession;
165
180
 
166
181
  // Useful to compare instead of instanceof with minified code
167
182
  this.type = 'CallSession';
@@ -1711,8 +1711,10 @@ var updateFrom = (instance , from ) => {
1711
1711
 
1712
1712
 
1713
1713
 
1714
+
1714
1715
 
1715
1716
 
1717
+
1716
1718
 
1717
1719
 
1718
1720
 
@@ -1729,6 +1731,7 @@ var updateFrom = (instance , from ) => {
1729
1731
 
1730
1732
 
1731
1733
 
1734
+
1732
1735
 
1733
1736
 
1734
1737
  class CallSession {
@@ -1748,8 +1751,12 @@ class CallSession {
1748
1751
 
1749
1752
 
1750
1753
 
1754
+
1755
+
1751
1756
 
1752
1757
 
1758
+
1759
+
1753
1760
 
1754
1761
 
1755
1762
 
@@ -1787,6 +1794,8 @@ class CallSession {
1787
1794
 
1788
1795
 
1789
1796
 
1797
+
1798
+
1790
1799
 
1791
1800
  constructor({
1792
1801
  answered,
@@ -1800,6 +1809,8 @@ class CallSession {
1800
1809
  paused,
1801
1810
  ringing,
1802
1811
  startTime,
1812
+ creationTime,
1813
+ endTime,
1803
1814
  cameraEnabled,
1804
1815
  dialedExtension,
1805
1816
  sipCallId,
@@ -1812,12 +1823,15 @@ class CallSession {
1812
1823
  recording,
1813
1824
  recordingPaused,
1814
1825
  videoRemotelyDowngraded,
1826
+ sipSession,
1815
1827
  } ) {
1816
1828
  this.callId = callId;
1817
1829
  this.sipCallId = sipCallId;
1818
1830
  this.displayName = displayName;
1819
1831
  this.number = number;
1832
+ this.creationTime = creationTime;
1820
1833
  this.startTime = startTime;
1834
+ this.endTime = endTime;
1821
1835
  this.isCaller = isCaller;
1822
1836
  this.answered = answered;
1823
1837
  this.answeredBySystem = answeredBySystem;
@@ -1836,6 +1850,7 @@ class CallSession {
1836
1850
  this.recording = recording || false;
1837
1851
  this.recordingPaused = recordingPaused || false;
1838
1852
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
1853
+ this.sipSession = sipSession;
1839
1854
 
1840
1855
  // Useful to compare instead of instanceof with minified code
1841
1856
  this.type = 'CallSession';
@@ -59,8 +59,10 @@ var updateFrom = (instance , from ) => {
59
59
 
60
60
 
61
61
 
62
+
62
63
 
63
64
 
65
+
64
66
 
65
67
 
66
68
 
@@ -77,6 +79,7 @@ var updateFrom = (instance , from ) => {
77
79
 
78
80
 
79
81
 
82
+
80
83
 
81
84
 
82
85
  class CallSession {
@@ -96,8 +99,12 @@ class CallSession {
96
99
 
97
100
 
98
101
 
102
+
103
+
99
104
 
100
105
 
106
+
107
+
101
108
 
102
109
 
103
110
 
@@ -135,6 +142,8 @@ class CallSession {
135
142
 
136
143
 
137
144
 
145
+
146
+
138
147
 
139
148
  constructor({
140
149
  answered,
@@ -148,6 +157,8 @@ class CallSession {
148
157
  paused,
149
158
  ringing,
150
159
  startTime,
160
+ creationTime,
161
+ endTime,
151
162
  cameraEnabled,
152
163
  dialedExtension,
153
164
  sipCallId,
@@ -160,12 +171,15 @@ class CallSession {
160
171
  recording,
161
172
  recordingPaused,
162
173
  videoRemotelyDowngraded,
174
+ sipSession,
163
175
  } ) {
164
176
  this.callId = callId;
165
177
  this.sipCallId = sipCallId;
166
178
  this.displayName = displayName;
167
179
  this.number = number;
180
+ this.creationTime = creationTime;
168
181
  this.startTime = startTime;
182
+ this.endTime = endTime;
169
183
  this.isCaller = isCaller;
170
184
  this.answered = answered;
171
185
  this.answeredBySystem = answeredBySystem;
@@ -184,6 +198,7 @@ class CallSession {
184
198
  this.recording = recording || false;
185
199
  this.recordingPaused = recordingPaused || false;
186
200
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
201
+ this.sipSession = sipSession;
187
202
 
188
203
  // Useful to compare instead of instanceof with minified code
189
204
  this.type = 'CallSession';
@@ -878,6 +893,7 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
878
893
  const ON_CAMERA_RESUMED = 'onCameraResumed';
879
894
  const ON_CALL_CANCELED = 'onCallCanceled';
880
895
  const ON_CALL_FAILED = 'onCallFailed';
896
+ const ON_CALL_REJECTED = 'onCallRejected';
881
897
  const ON_CALL_ENDED = 'onCallEnded';
882
898
  const ON_CALL_ENDING = 'onCallEnding';
883
899
  const ON_MESSAGE = 'onMessage';
@@ -922,6 +938,7 @@ const events = [
922
938
  ON_CAMERA_DISABLED,
923
939
  ON_CALL_FAILED,
924
940
  ON_CALL_ENDED,
941
+ ON_CALL_REJECTED,
925
942
  ON_MESSAGE,
926
943
  ON_REINVITE,
927
944
  ON_TRACK,
@@ -1278,6 +1295,7 @@ class WebRTCPhone extends Emitter {
1278
1295
 
1279
1296
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
1280
1297
  const callSession = this._createCallSession(sipSession);
1298
+ callSession.endTime = new Date();
1281
1299
  const wasCurrentSession = this._onCallTerminated(sipSession);
1282
1300
 
1283
1301
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -1997,6 +2015,7 @@ class WebRTCPhone extends Emitter {
1997
2015
  return Promise.resolve(null);
1998
2016
  }
1999
2017
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
2018
+ callSession.creationTime = new Date();
2000
2019
 
2001
2020
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
2002
2021
 
@@ -2275,6 +2294,7 @@ class WebRTCPhone extends Emitter {
2275
2294
  callSession);
2276
2295
  }
2277
2296
 
2297
+ callSession.creationTime = new Date();
2278
2298
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
2279
2299
  });
2280
2300
 
@@ -2314,6 +2334,13 @@ class WebRTCPhone extends Emitter {
2314
2334
  this.eventEmitter.emit(ON_CALL_ERROR, e);
2315
2335
  });
2316
2336
 
2337
+ this.client.on(this.client.REJECTED, session => {
2338
+ logger.info('WebRTC call rejected', session.id);
2339
+ const callSession = this._createCallSession(session);
2340
+ callSession.endTime = new Date();
2341
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
2342
+ });
2343
+
2317
2344
  this.client.on(this.client.UNREGISTERED, () => {
2318
2345
  logger.info('WebRTC unregistered');
2319
2346
  this.eventEmitter.emit(ON_UNREGISTERED);
@@ -2526,6 +2553,7 @@ class WebRTCPhone extends Emitter {
2526
2553
  const number = identity ? identity.uri._normal.user : null;
2527
2554
  const { state } = sipSession || {};
2528
2555
  const sessionId = this.getSipSessionId(sipSession);
2556
+ fromSession = fromSession || this.callSessions[sessionId];
2529
2557
 
2530
2558
  const callSession = new CallSession({
2531
2559
  callId: fromSession && fromSession.callId,
@@ -2533,6 +2561,8 @@ class WebRTCPhone extends Emitter {
2533
2561
  sipStatus: state,
2534
2562
  displayName: identity ? identity.displayName || number : number,
2535
2563
  startTime: fromSession ? fromSession.startTime : new Date(),
2564
+ creationTime: fromSession ? fromSession.creationTime : null,
2565
+ endTime: fromSession ? fromSession.endTime : null,
2536
2566
  answered: state === SessionState.Established,
2537
2567
  paused: this.client.isCallHeld(sipSession),
2538
2568
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -2543,6 +2573,7 @@ class WebRTCPhone extends Emitter {
2543
2573
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
2544
2574
  recording: fromSession ? fromSession.isRecording() : false,
2545
2575
  recordingPaused: false, // @TODO
2576
+ sipSession,
2546
2577
  ...extra,
2547
2578
  });
2548
2579
 
@@ -2553,4 +2584,4 @@ class WebRTCPhone extends Emitter {
2553
2584
  }
2554
2585
 
2555
2586
  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 };
2587
+ 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;
@@ -37,8 +37,10 @@ var updateFrom = (instance , from ) => {
37
37
 
38
38
 
39
39
 
40
+
40
41
 
41
42
 
43
+
42
44
 
43
45
 
44
46
 
@@ -55,6 +57,7 @@ var updateFrom = (instance , from ) => {
55
57
 
56
58
 
57
59
 
60
+
58
61
 
59
62
 
60
63
  class CallSession {
@@ -74,8 +77,12 @@ class CallSession {
74
77
 
75
78
 
76
79
 
80
+
81
+
77
82
 
78
83
 
84
+
85
+
79
86
 
80
87
 
81
88
 
@@ -113,6 +120,8 @@ class CallSession {
113
120
 
114
121
 
115
122
 
123
+
124
+
116
125
 
117
126
  constructor({
118
127
  answered,
@@ -126,6 +135,8 @@ class CallSession {
126
135
  paused,
127
136
  ringing,
128
137
  startTime,
138
+ creationTime,
139
+ endTime,
129
140
  cameraEnabled,
130
141
  dialedExtension,
131
142
  sipCallId,
@@ -138,12 +149,15 @@ class CallSession {
138
149
  recording,
139
150
  recordingPaused,
140
151
  videoRemotelyDowngraded,
152
+ sipSession,
141
153
  } ) {
142
154
  this.callId = callId;
143
155
  this.sipCallId = sipCallId;
144
156
  this.displayName = displayName;
145
157
  this.number = number;
158
+ this.creationTime = creationTime;
146
159
  this.startTime = startTime;
160
+ this.endTime = endTime;
147
161
  this.isCaller = isCaller;
148
162
  this.answered = answered;
149
163
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +176,7 @@ class CallSession {
162
176
  this.recording = recording || false;
163
177
  this.recordingPaused = recordingPaused || false;
164
178
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
179
+ this.sipSession = sipSession;
165
180
 
166
181
  // Useful to compare instead of instanceof with minified code
167
182
  this.type = 'CallSession';
@@ -37,8 +37,10 @@ var updateFrom = (instance , from ) => {
37
37
 
38
38
 
39
39
 
40
+
40
41
 
41
42
 
43
+
42
44
 
43
45
 
44
46
 
@@ -55,6 +57,7 @@ var updateFrom = (instance , from ) => {
55
57
 
56
58
 
57
59
 
60
+
58
61
 
59
62
 
60
63
  class CallSession {
@@ -74,8 +77,12 @@ class CallSession {
74
77
 
75
78
 
76
79
 
80
+
81
+
77
82
 
78
83
 
84
+
85
+
79
86
 
80
87
 
81
88
 
@@ -113,6 +120,8 @@ class CallSession {
113
120
 
114
121
 
115
122
 
123
+
124
+
116
125
 
117
126
  constructor({
118
127
  answered,
@@ -126,6 +135,8 @@ class CallSession {
126
135
  paused,
127
136
  ringing,
128
137
  startTime,
138
+ creationTime,
139
+ endTime,
129
140
  cameraEnabled,
130
141
  dialedExtension,
131
142
  sipCallId,
@@ -138,12 +149,15 @@ class CallSession {
138
149
  recording,
139
150
  recordingPaused,
140
151
  videoRemotelyDowngraded,
152
+ sipSession,
141
153
  } ) {
142
154
  this.callId = callId;
143
155
  this.sipCallId = sipCallId;
144
156
  this.displayName = displayName;
145
157
  this.number = number;
158
+ this.creationTime = creationTime;
146
159
  this.startTime = startTime;
160
+ this.endTime = endTime;
147
161
  this.isCaller = isCaller;
148
162
  this.answered = answered;
149
163
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +176,7 @@ class CallSession {
162
176
  this.recording = recording || false;
163
177
  this.recordingPaused = recordingPaused || false;
164
178
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
179
+ this.sipSession = sipSession;
165
180
 
166
181
  // Useful to compare instead of instanceof with minified code
167
182
  this.type = 'CallSession';
@@ -37,8 +37,10 @@ var updateFrom = (instance , from ) => {
37
37
 
38
38
 
39
39
 
40
+
40
41
 
41
42
 
43
+
42
44
 
43
45
 
44
46
 
@@ -55,6 +57,7 @@ var updateFrom = (instance , from ) => {
55
57
 
56
58
 
57
59
 
60
+
58
61
 
59
62
 
60
63
  class CallSession {
@@ -74,8 +77,12 @@ class CallSession {
74
77
 
75
78
 
76
79
 
80
+
81
+
77
82
 
78
83
 
84
+
85
+
79
86
 
80
87
 
81
88
 
@@ -113,6 +120,8 @@ class CallSession {
113
120
 
114
121
 
115
122
 
123
+
124
+
116
125
 
117
126
  constructor({
118
127
  answered,
@@ -126,6 +135,8 @@ class CallSession {
126
135
  paused,
127
136
  ringing,
128
137
  startTime,
138
+ creationTime,
139
+ endTime,
129
140
  cameraEnabled,
130
141
  dialedExtension,
131
142
  sipCallId,
@@ -138,12 +149,15 @@ class CallSession {
138
149
  recording,
139
150
  recordingPaused,
140
151
  videoRemotelyDowngraded,
152
+ sipSession,
141
153
  } ) {
142
154
  this.callId = callId;
143
155
  this.sipCallId = sipCallId;
144
156
  this.displayName = displayName;
145
157
  this.number = number;
158
+ this.creationTime = creationTime;
146
159
  this.startTime = startTime;
160
+ this.endTime = endTime;
147
161
  this.isCaller = isCaller;
148
162
  this.answered = answered;
149
163
  this.answeredBySystem = answeredBySystem;
@@ -162,6 +176,7 @@ class CallSession {
162
176
  this.recording = recording || false;
163
177
  this.recordingPaused = recordingPaused || false;
164
178
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
179
+ this.sipSession = sipSession;
165
180
 
166
181
  // Useful to compare instead of instanceof with minified code
167
182
  this.type = 'CallSession';