@wazo/sdk 0.37.22 → 0.37.23

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 (113) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +26 -0
  3. package/esm/__tests__/web-rtc-client.test.js +40 -52
  4. package/esm/api/call-logd.js +7 -0
  5. package/esm/api/calld.js +10 -0
  6. package/esm/api/chatd.js +7 -0
  7. package/esm/api/confd.js +3 -0
  8. package/esm/api/ctid-ng.js +10 -0
  9. package/esm/api/dird.js +3 -0
  10. package/esm/api-client.js +26 -0
  11. package/esm/checker/Checker.js +40 -52
  12. package/esm/checker/checks/aor.js +26 -0
  13. package/esm/checker/checks/api.js +26 -0
  14. package/esm/checker/checks/index.js +40 -52
  15. package/esm/checker/checks/webrtc-transport.js +40 -52
  16. package/esm/checker/checks/webrtc.js +40 -52
  17. package/esm/domain/AdHocAPIConference.js +26 -0
  18. package/esm/domain/Call.js +3 -0
  19. package/esm/domain/CallLog.js +7 -0
  20. package/esm/domain/ChatMessage.js +4 -0
  21. package/esm/domain/ChatRoom.js +3 -0
  22. package/esm/domain/Contact.js +3 -0
  23. package/esm/domain/Features.js +26 -0
  24. package/esm/domain/Meeting.js +3 -0
  25. package/esm/domain/Phone/CTIPhone.js +30 -0
  26. package/esm/domain/Phone/WebRTCPhone.js +14 -12
  27. package/esm/domain/Recording.js +3 -0
  28. package/esm/domain/Voicemail.js +3 -0
  29. package/esm/domain/__tests__/Call.test.js +3 -0
  30. package/esm/domain/__tests__/CallLog.test.js +7 -0
  31. package/esm/domain/__tests__/Contact.test.js +3 -0
  32. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  33. package/esm/index.js +57 -63
  34. package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
  35. package/esm/service/CallApi.js +26 -0
  36. package/esm/service/getApiClient.js +26 -0
  37. package/esm/simple/Auth.js +57 -63
  38. package/esm/simple/Configuration.js +57 -63
  39. package/esm/simple/Directory.js +26 -0
  40. package/esm/simple/Phone.js +57 -63
  41. package/esm/simple/index.js +57 -63
  42. package/esm/simple/room/LocalParticipant.js +57 -63
  43. package/esm/simple/room/Participant.js +57 -63
  44. package/esm/simple/room/RemoteParticipant.js +57 -63
  45. package/esm/simple/room/Room.js +57 -63
  46. package/esm/simple/room/SipRoom.js +57 -63
  47. package/esm/simple/room/Stream.js +57 -63
  48. package/esm/simple/room/__tests__/RemoteParticipant.test.js +57 -63
  49. package/esm/simple/utils.js +57 -63
  50. package/esm/web-rtc-client.js +40 -52
  51. package/lib/__tests__/api-client.test.js +26 -0
  52. package/lib/__tests__/web-rtc-client.test.js +40 -52
  53. package/lib/api/call-logd.js +7 -0
  54. package/lib/api/calld.js +10 -0
  55. package/lib/api/chatd.js +7 -0
  56. package/lib/api/confd.js +3 -0
  57. package/lib/api/ctid-ng.js +10 -0
  58. package/lib/api/dird.js +3 -0
  59. package/lib/api-client.js +26 -0
  60. package/lib/checker/Checker.js +40 -52
  61. package/lib/checker/checks/aor.js +26 -0
  62. package/lib/checker/checks/api.js +26 -0
  63. package/lib/checker/checks/index.js +40 -52
  64. package/lib/checker/checks/webrtc-transport.js +40 -52
  65. package/lib/checker/checks/webrtc.js +40 -52
  66. package/lib/domain/AdHocAPIConference.js +26 -0
  67. package/lib/domain/Call.js +3 -0
  68. package/lib/domain/CallLog.js +7 -0
  69. package/lib/domain/ChatMessage.js +4 -0
  70. package/lib/domain/ChatRoom.js +3 -0
  71. package/lib/domain/Contact.js +3 -0
  72. package/lib/domain/Features.js +26 -0
  73. package/lib/domain/Meeting.js +3 -0
  74. package/lib/domain/Phone/CTIPhone.js +30 -0
  75. package/lib/domain/Phone/WebRTCPhone.js +14 -12
  76. package/lib/domain/Recording.js +3 -0
  77. package/lib/domain/Voicemail.js +3 -0
  78. package/lib/domain/__tests__/Call.test.js +3 -0
  79. package/lib/domain/__tests__/CallLog.test.js +7 -0
  80. package/lib/domain/__tests__/Contact.test.js +3 -0
  81. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  82. package/lib/index.js +57 -63
  83. package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
  84. package/lib/service/CallApi.js +26 -0
  85. package/lib/service/getApiClient.js +26 -0
  86. package/lib/simple/Auth.js +57 -63
  87. package/lib/simple/Configuration.js +57 -63
  88. package/lib/simple/Directory.js +26 -0
  89. package/lib/simple/Phone.js +57 -63
  90. package/lib/simple/index.js +57 -63
  91. package/lib/simple/room/LocalParticipant.js +57 -63
  92. package/lib/simple/room/Participant.js +57 -63
  93. package/lib/simple/room/RemoteParticipant.js +57 -63
  94. package/lib/simple/room/Room.js +57 -63
  95. package/lib/simple/room/SipRoom.js +57 -63
  96. package/lib/simple/room/Stream.js +57 -63
  97. package/lib/simple/room/__tests__/RemoteParticipant.test.js +57 -63
  98. package/lib/simple/utils.js +57 -63
  99. package/lib/web-rtc-client.js +40 -52
  100. package/package.json +1 -1
  101. package/src/domain/Call.js +3 -0
  102. package/src/domain/CallLog.js +4 -0
  103. package/src/domain/ChatMessage.js +4 -0
  104. package/src/domain/ChatRoom.js +3 -0
  105. package/src/domain/Contact.js +3 -0
  106. package/src/domain/Meeting.js +3 -0
  107. package/src/domain/Phone/CTIPhone.js +4 -0
  108. package/src/domain/Phone/Phone.js +2 -0
  109. package/src/domain/Phone/WebRTCPhone.js +14 -12
  110. package/src/domain/Recording.js +3 -0
  111. package/src/domain/Voicemail.js +3 -0
  112. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  113. package/src/web-rtc-client.js +14 -14
@@ -84,6 +84,10 @@ export default class CallLog {
84
84
  }
85
85
 
86
86
  static parseMany(plain: Response): Array<CallLog> {
87
+ if (!plain || !plain.items) {
88
+ return [];
89
+ }
90
+
87
91
  return plain.items.map(item => CallLog.parse(item));
88
92
  }
89
93
 
@@ -42,6 +42,10 @@ export default class ChatMessage {
42
42
  read: boolean;
43
43
 
44
44
  static parseMany(plain: ChatMessageListResponse): Array<ChatMessage> {
45
+ if (!plain || !plain.items) {
46
+ return [];
47
+ }
48
+
45
49
  return plain.items.map(item => ChatMessage.parse(item));
46
50
  }
47
51
 
@@ -22,6 +22,9 @@ export default class ChatRoom {
22
22
  users: Array<ChatUser>;
23
23
 
24
24
  static parseMany(plain: RootListResponse): Array<ChatRoom> {
25
+ if (!plain || !plain.items) {
26
+ return [];
27
+ }
25
28
  return plain.items.map(item => ChatRoom.parse(item));
26
29
  }
27
30
 
@@ -281,6 +281,9 @@ export default class Contact {
281
281
  }
282
282
 
283
283
  static parseMany(response: ContactsResponse): Array<Contact> {
284
+ if (!response || !response.results) {
285
+ return [];
286
+ }
284
287
  return response.results.map(r => Contact.parse(r, response.column_types));
285
288
  }
286
289
 
@@ -38,6 +38,9 @@ export default class Meeting {
38
38
  }
39
39
 
40
40
  static parseMany(items: MeetingCreationResponse[]): Array<Meeting> {
41
+ if (!items) {
42
+ return [];
43
+ }
41
44
  return items.map(plain => Meeting.parse(plain));
42
45
  }
43
46
 
@@ -280,6 +280,10 @@ export default class CTIPhone extends Emitter implements Phone {
280
280
  return false;
281
281
  }
282
282
 
283
+ hasAVideoTrack(): boolean {
284
+ return false;
285
+ }
286
+
283
287
  getLocalStreamForCall(): ?MediaStream {
284
288
  return null;
285
289
  }
@@ -80,6 +80,8 @@ export interface Phone {
80
80
 
81
81
  hasVideo(callSession: CallSession): boolean;
82
82
 
83
+ hasAVideoTrack(callSession: CallSession): boolean;
84
+
83
85
  isWebRTC(): boolean;
84
86
 
85
87
  getUserAgent(): string;
@@ -571,18 +571,20 @@ export default class WebRTCPhone extends Emitter implements Phone {
571
571
  screenTrack,
572
572
  });
573
573
 
574
- screenTrack.onended = () => {
575
- logger.info('WebRTC phone - on screenshare ended', {
576
- hadVideo,
577
- id: this.getSipSessionId(sipSession),
578
- screenTrack,
579
- });
580
-
581
- this.eventEmitter.emit(
582
- ON_SHARE_SCREEN_ENDING,
583
- this._createCallSession(sipSession, callSession),
584
- );
585
- };
574
+ if (screenTrack) {
575
+ screenTrack.onended = () => {
576
+ logger.info('WebRTC phone - on screenshare ended', {
577
+ hadVideo,
578
+ id: this.getSipSessionId(sipSession),
579
+ screenTrack,
580
+ });
581
+
582
+ this.eventEmitter.emit(
583
+ ON_SHARE_SCREEN_ENDING,
584
+ this._createCallSession(sipSession, callSession),
585
+ );
586
+ };
587
+ }
586
588
 
587
589
  this.currentScreenShare = {
588
590
  stream: screenStream,
@@ -25,6 +25,9 @@ export default class Recording {
25
25
  uuid: string;
26
26
 
27
27
  static parseMany(recordings: RecordingResponse[] = []): Recording[] {
28
+ if (!recordings) {
29
+ return [];
30
+ }
28
31
  return recordings.map(item => Recording.parse(item));
29
32
  }
30
33
 
@@ -61,6 +61,9 @@ export default class Voicemail {
61
61
  }
62
62
 
63
63
  static parseMany(plain: Response): Array<Voicemail> {
64
+ if (!plain) {
65
+ return [];
66
+ }
64
67
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
65
68
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
66
69
 
@@ -12,11 +12,9 @@ import { SessionDescriptionHandler }
12
12
  import { SessionDescriptionHandlerOptions }
13
13
  from 'sip.js/lib/platform/web/session-description-handler/session-description-handler-options';
14
14
  import IssueReporter from '../service/IssueReporter';
15
- import { areCandidateValid, fixSdp, parseCandidate } from '../utils/sdp';
15
+ import { fixSdp, parseCandidate } from '../utils/sdp';
16
16
 
17
17
  const wazoLogger = IssueReporter ? IssueReporter.loggerFor('webrtc-sdh') : console;
18
- const MAX_WAIT_FOR_ICE_TRIES = 20;
19
- const WAIT_FOR_ICE_TIMEOUT = 500;
20
18
 
21
19
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
22
20
  export const wazoMediaStreamFactory = (constraints: Object): Promise<MediaStream> => {
@@ -206,38 +204,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
206
204
  this._peerConnection = undefined;
207
205
  }
208
206
 
209
- async _waitForValidGatheredIce(): Object {
210
- let tries = 0;
211
-
212
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
213
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
214
- tries,
215
- max: MAX_WAIT_FOR_ICE_TRIES,
216
- });
217
-
218
- tries++;
219
-
220
- // eslint-disable-next-line no-await-in-loop
221
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
222
- }
223
-
224
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
225
- const errorMsg = 'No valid candidates found, can\'t answer the call';
226
- const error = new Error(errorMsg);
227
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
228
-
229
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
230
- this.eventEmitter.emit('error', error);
231
-
232
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
233
- }
234
-
235
- // eslint-disable-next-line
236
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
237
-
238
- return this.getLocalSessionDescription();
239
- }
240
-
241
207
  // Overridden to send `inactive` in conference
242
208
  updateDirection(options?: SessionDescriptionHandlerOptions, isConference: boolean = false,
243
209
  audioOnly: boolean = false): Promise<void> {
@@ -2101,25 +2101,25 @@ export default class WebRTCClient extends Emitter {
2101
2101
 
2102
2102
  stats.forEach(report => {
2103
2103
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
2104
- audioBytesSent += report.bytesSent + report.headerBytesSent;
2104
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
2105
2105
  }
2106
2106
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
2107
- audioBytesSent += report.bytesSent;
2107
+ audioBytesSent += Number(report.bytesSent);
2108
2108
  }
2109
2109
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
2110
- videoBytesSent += report.bytesSent + report.headerBytesSent;
2110
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
2111
2111
  }
2112
2112
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
2113
- packetsLost += report.packetsLost;
2114
- networkStats.packetsReceived = report.packetsReceived;
2115
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
2113
+ packetsLost += Number(report.packetsLost);
2114
+ networkStats.packetsReceived = Number(report.packetsReceived);
2115
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
2116
2116
  }
2117
2117
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
2118
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
2118
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
2119
2119
  }
2120
2120
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
2121
2121
  if ('framesPerSecond' in report) {
2122
- networkStats.framesPerSecond = report.framesPerSecond;
2122
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
2123
2123
  }
2124
2124
  if ('framerateMean' in report) {
2125
2125
  // framerateMean is only available in FF
@@ -2127,16 +2127,16 @@ export default class WebRTCClient extends Emitter {
2127
2127
  }
2128
2128
  }
2129
2129
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
2130
- packetsLost += report.packetsLost;
2131
- networkStats.roundTripTime = report.roundTripTime;
2132
- networkStats.jitter = report.jitter;
2130
+ packetsLost += Number(report.packetsLost);
2131
+ networkStats.roundTripTime = Number(report.roundTripTime);
2132
+ networkStats.jitter = Number(report.jitter);
2133
2133
  }
2134
2134
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
2135
- packetsLost += report.packetsLost;
2135
+ packetsLost += Number(report.packetsLost);
2136
2136
  }
2137
2137
  if (report.type === 'transport') {
2138
- transportSent += report.bytesSent;
2139
- transportReceived += report.bytesReceived;
2138
+ transportSent += Number(report.bytesSent);
2139
+ transportReceived += Number(report.bytesReceived);
2140
2140
  }
2141
2141
  });
2142
2142