@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
@@ -724,10 +724,6 @@ const getSrflxOrRelay = (candidates ) =>
724
724
  candidates
725
725
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
726
726
 
727
- const areCandidateValid = (candidates ) =>
728
- getSrflxOrRelay(candidates)
729
- .length > 0;
730
-
731
727
  const getVideoDirection = (sdp ) => {
732
728
  const parsedSdp = sdpParser.parse(sdp);
733
729
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -780,8 +776,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
780
776
  /* global RTCSessionDescriptionInit, navigator */
781
777
 
782
778
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
783
- const MAX_WAIT_FOR_ICE_TRIES = 20;
784
- const WAIT_FOR_ICE_TIMEOUT = 500;
785
779
 
786
780
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
787
781
  const wazoMediaStreamFactory = (constraints ) => {
@@ -971,38 +965,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
971
965
  this._peerConnection = undefined;
972
966
  }
973
967
 
974
- async _waitForValidGatheredIce() {
975
- let tries = 0;
976
-
977
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
978
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
979
- tries,
980
- max: MAX_WAIT_FOR_ICE_TRIES,
981
- });
982
-
983
- tries++;
984
-
985
- // eslint-disable-next-line no-await-in-loop
986
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
987
- }
988
-
989
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
990
- const errorMsg = 'No valid candidates found, can\'t answer the call';
991
- const error = new Error(errorMsg);
992
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
993
-
994
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
995
- this.eventEmitter.emit('error', error);
996
-
997
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
998
- }
999
-
1000
- // eslint-disable-next-line
1001
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
1002
-
1003
- return this.getLocalSessionDescription();
1004
- }
1005
-
1006
968
  // Overridden to send `inactive` in conference
1007
969
  updateDirection(options , isConference = false,
1008
970
  audioOnly = false) {
@@ -2112,6 +2074,9 @@ class Contact {
2112
2074
  }
2113
2075
 
2114
2076
  static parseMany(response ) {
2077
+ if (!response || !response.results) {
2078
+ return [];
2079
+ }
2115
2080
  return response.results.map(r => Contact.parse(r, response.column_types));
2116
2081
  }
2117
2082
 
@@ -3219,6 +3184,9 @@ class Meeting {
3219
3184
  }
3220
3185
 
3221
3186
  static parseMany(items ) {
3187
+ if (!items) {
3188
+ return [];
3189
+ }
3222
3190
  return items.map(plain => Meeting.parse(plain));
3223
3191
  }
3224
3192
 
@@ -3421,6 +3389,10 @@ class ChatMessage {
3421
3389
 
3422
3390
 
3423
3391
  static parseMany(plain ) {
3392
+ if (!plain || !plain.items) {
3393
+ return [];
3394
+ }
3395
+
3424
3396
  return plain.items.map(item => ChatMessage.parse(item));
3425
3397
  }
3426
3398
 
@@ -3530,6 +3502,9 @@ class Voicemail {
3530
3502
  }
3531
3503
 
3532
3504
  static parseMany(plain ) {
3505
+ if (!plain) {
3506
+ return [];
3507
+ }
3533
3508
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3534
3509
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3535
3510
 
@@ -3639,6 +3614,9 @@ class Call {
3639
3614
 
3640
3615
 
3641
3616
  static parseMany(plain ) {
3617
+ if (!plain) {
3618
+ return [];
3619
+ }
3642
3620
  return plain.map((plainCall ) => Call.parse(plainCall));
3643
3621
  }
3644
3622
 
@@ -3811,6 +3789,9 @@ class Recording {
3811
3789
 
3812
3790
 
3813
3791
  static parseMany(recordings = []) {
3792
+ if (!recordings) {
3793
+ return [];
3794
+ }
3814
3795
  return recordings.map(item => Recording.parse(item));
3815
3796
  }
3816
3797
 
@@ -3912,6 +3893,10 @@ class CallLog {
3912
3893
  }
3913
3894
 
3914
3895
  static parseMany(plain ) {
3896
+ if (!plain || !plain.items) {
3897
+ return [];
3898
+ }
3899
+
3915
3900
  return plain.items.map(item => CallLog.parse(item));
3916
3901
  }
3917
3902
 
@@ -4484,6 +4469,9 @@ class ChatRoom {
4484
4469
 
4485
4470
 
4486
4471
  static parseMany(plain ) {
4472
+ if (!plain || !plain.items) {
4473
+ return [];
4474
+ }
4487
4475
  return plain.items.map(item => ChatRoom.parse(item));
4488
4476
  }
4489
4477
 
@@ -7360,25 +7348,25 @@ class WebRTCClient extends Emitter {
7360
7348
 
7361
7349
  stats.forEach(report => {
7362
7350
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7363
- audioBytesSent += report.bytesSent + report.headerBytesSent;
7351
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7364
7352
  }
7365
7353
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7366
- audioBytesSent += report.bytesSent;
7354
+ audioBytesSent += Number(report.bytesSent);
7367
7355
  }
7368
7356
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7369
- videoBytesSent += report.bytesSent + report.headerBytesSent;
7357
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7370
7358
  }
7371
7359
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
7372
- packetsLost += report.packetsLost;
7373
- networkStats.packetsReceived = report.packetsReceived;
7374
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
7360
+ packetsLost += Number(report.packetsLost);
7361
+ networkStats.packetsReceived = Number(report.packetsReceived);
7362
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7375
7363
  }
7376
7364
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7377
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
7365
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7378
7366
  }
7379
7367
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7380
7368
  if ('framesPerSecond' in report) {
7381
- networkStats.framesPerSecond = report.framesPerSecond;
7369
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
7382
7370
  }
7383
7371
  if ('framerateMean' in report) {
7384
7372
  // framerateMean is only available in FF
@@ -7386,16 +7374,16 @@ class WebRTCClient extends Emitter {
7386
7374
  }
7387
7375
  }
7388
7376
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
7389
- packetsLost += report.packetsLost;
7390
- networkStats.roundTripTime = report.roundTripTime;
7391
- networkStats.jitter = report.jitter;
7377
+ packetsLost += Number(report.packetsLost);
7378
+ networkStats.roundTripTime = Number(report.roundTripTime);
7379
+ networkStats.jitter = Number(report.jitter);
7392
7380
  }
7393
7381
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
7394
- packetsLost += report.packetsLost;
7382
+ packetsLost += Number(report.packetsLost);
7395
7383
  }
7396
7384
  if (report.type === 'transport') {
7397
- transportSent += report.bytesSent;
7398
- transportReceived += report.bytesReceived;
7385
+ transportSent += Number(report.bytesSent);
7386
+ transportReceived += Number(report.bytesReceived);
7399
7387
  }
7400
7388
  });
7401
7389
 
@@ -76,6 +76,9 @@ class Call {
76
76
 
77
77
 
78
78
  static parseMany(plain ) {
79
+ if (!plain) {
80
+ return [];
81
+ }
79
82
  return plain.map((plainCall ) => Call.parse(plainCall));
80
83
  }
81
84
 
@@ -1737,6 +1740,9 @@ class Contact {
1737
1740
  }
1738
1741
 
1739
1742
  static parseMany(response ) {
1743
+ if (!response || !response.results) {
1744
+ return [];
1745
+ }
1740
1746
  return response.results.map(r => Contact.parse(r, response.column_types));
1741
1747
  }
1742
1748
 
@@ -2844,6 +2850,9 @@ class Meeting {
2844
2850
  }
2845
2851
 
2846
2852
  static parseMany(items ) {
2853
+ if (!items) {
2854
+ return [];
2855
+ }
2847
2856
  return items.map(plain => Meeting.parse(plain));
2848
2857
  }
2849
2858
 
@@ -3046,6 +3055,10 @@ class ChatMessage {
3046
3055
 
3047
3056
 
3048
3057
  static parseMany(plain ) {
3058
+ if (!plain || !plain.items) {
3059
+ return [];
3060
+ }
3061
+
3049
3062
  return plain.items.map(item => ChatMessage.parse(item));
3050
3063
  }
3051
3064
 
@@ -3155,6 +3168,9 @@ class Voicemail {
3155
3168
  }
3156
3169
 
3157
3170
  static parseMany(plain ) {
3171
+ if (!plain) {
3172
+ return [];
3173
+ }
3158
3174
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3159
3175
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3160
3176
 
@@ -3230,6 +3246,9 @@ class Recording {
3230
3246
 
3231
3247
 
3232
3248
  static parseMany(recordings = []) {
3249
+ if (!recordings) {
3250
+ return [];
3251
+ }
3233
3252
  return recordings.map(item => Recording.parse(item));
3234
3253
  }
3235
3254
 
@@ -3331,6 +3350,10 @@ class CallLog {
3331
3350
  }
3332
3351
 
3333
3352
  static parseMany(plain ) {
3353
+ if (!plain || !plain.items) {
3354
+ return [];
3355
+ }
3356
+
3334
3357
  return plain.items.map(item => CallLog.parse(item));
3335
3358
  }
3336
3359
 
@@ -3888,6 +3911,9 @@ class ChatRoom {
3888
3911
 
3889
3912
 
3890
3913
  static parseMany(plain ) {
3914
+ if (!plain || !plain.items) {
3915
+ return [];
3916
+ }
3891
3917
  return plain.items.map(item => ChatRoom.parse(item));
3892
3918
  }
3893
3919
 
@@ -71,6 +71,9 @@ class Call {
71
71
 
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  return plain.map((plainCall ) => Call.parse(plainCall));
75
78
  }
76
79
 
@@ -54,6 +54,9 @@ class Recording {
54
54
 
55
55
 
56
56
  static parseMany(recordings = []) {
57
+ if (!recordings) {
58
+ return [];
59
+ }
57
60
  return recordings.map(item => Recording.parse(item));
58
61
  }
59
62
 
@@ -155,6 +158,10 @@ class CallLog {
155
158
  }
156
159
 
157
160
  static parseMany(plain ) {
161
+ if (!plain || !plain.items) {
162
+ return [];
163
+ }
164
+
158
165
  return plain.items.map(item => CallLog.parse(item));
159
166
  }
160
167
 
@@ -52,6 +52,10 @@ class ChatMessage {
52
52
 
53
53
 
54
54
  static parseMany(plain ) {
55
+ if (!plain || !plain.items) {
56
+ return [];
57
+ }
58
+
55
59
  return plain.items.map(item => ChatMessage.parse(item));
56
60
  }
57
61
 
@@ -31,6 +31,9 @@ class ChatRoom {
31
31
 
32
32
 
33
33
  static parseMany(plain ) {
34
+ if (!plain || !plain.items) {
35
+ return [];
36
+ }
34
37
  return plain.items.map(item => ChatRoom.parse(item));
35
38
  }
36
39
 
@@ -325,6 +325,9 @@ class Contact {
325
325
  }
326
326
 
327
327
  static parseMany(response ) {
328
+ if (!response || !response.results) {
329
+ return [];
330
+ }
328
331
  return response.results.map(r => Contact.parse(r, response.column_types));
329
332
  }
330
333
 
@@ -1531,6 +1531,9 @@ class Contact {
1531
1531
  }
1532
1532
 
1533
1533
  static parseMany(response ) {
1534
+ if (!response || !response.results) {
1535
+ return [];
1536
+ }
1534
1537
  return response.results.map(r => Contact.parse(r, response.column_types));
1535
1538
  }
1536
1539
 
@@ -2638,6 +2641,9 @@ class Meeting {
2638
2641
  }
2639
2642
 
2640
2643
  static parseMany(items ) {
2644
+ if (!items) {
2645
+ return [];
2646
+ }
2641
2647
  return items.map(plain => Meeting.parse(plain));
2642
2648
  }
2643
2649
 
@@ -2840,6 +2846,10 @@ class ChatMessage {
2840
2846
 
2841
2847
 
2842
2848
  static parseMany(plain ) {
2849
+ if (!plain || !plain.items) {
2850
+ return [];
2851
+ }
2852
+
2843
2853
  return plain.items.map(item => ChatMessage.parse(item));
2844
2854
  }
2845
2855
 
@@ -2949,6 +2959,9 @@ class Voicemail {
2949
2959
  }
2950
2960
 
2951
2961
  static parseMany(plain ) {
2962
+ if (!plain) {
2963
+ return [];
2964
+ }
2952
2965
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2953
2966
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2954
2967
 
@@ -3058,6 +3071,9 @@ class Call {
3058
3071
 
3059
3072
 
3060
3073
  static parseMany(plain ) {
3074
+ if (!plain) {
3075
+ return [];
3076
+ }
3061
3077
  return plain.map((plainCall ) => Call.parse(plainCall));
3062
3078
  }
3063
3079
 
@@ -3230,6 +3246,9 @@ class Recording {
3230
3246
 
3231
3247
 
3232
3248
  static parseMany(recordings = []) {
3249
+ if (!recordings) {
3250
+ return [];
3251
+ }
3233
3252
  return recordings.map(item => Recording.parse(item));
3234
3253
  }
3235
3254
 
@@ -3331,6 +3350,10 @@ class CallLog {
3331
3350
  }
3332
3351
 
3333
3352
  static parseMany(plain ) {
3353
+ if (!plain || !plain.items) {
3354
+ return [];
3355
+ }
3356
+
3334
3357
  return plain.items.map(item => CallLog.parse(item));
3335
3358
  }
3336
3359
 
@@ -3888,6 +3911,9 @@ class ChatRoom {
3888
3911
 
3889
3912
 
3890
3913
  static parseMany(plain ) {
3914
+ if (!plain || !plain.items) {
3915
+ return [];
3916
+ }
3891
3917
  return plain.items.map(item => ChatRoom.parse(item));
3892
3918
  }
3893
3919
 
@@ -48,6 +48,9 @@ class Meeting {
48
48
  }
49
49
 
50
50
  static parseMany(items ) {
51
+ if (!items) {
52
+ return [];
53
+ }
51
54
  return items.map(plain => Meeting.parse(plain));
52
55
  }
53
56
 
@@ -844,6 +844,9 @@ class Contact {
844
844
  }
845
845
 
846
846
  static parseMany(response ) {
847
+ if (!response || !response.results) {
848
+ return [];
849
+ }
847
850
  return response.results.map(r => Contact.parse(r, response.column_types));
848
851
  }
849
852
 
@@ -1550,6 +1553,9 @@ class Call {
1550
1553
 
1551
1554
 
1552
1555
  static parseMany(plain ) {
1556
+ if (!plain) {
1557
+ return [];
1558
+ }
1553
1559
  return plain.map((plainCall ) => Call.parse(plainCall));
1554
1560
  }
1555
1561
 
@@ -2093,6 +2099,9 @@ class Recording {
2093
2099
 
2094
2100
 
2095
2101
  static parseMany(recordings = []) {
2102
+ if (!recordings) {
2103
+ return [];
2104
+ }
2096
2105
  return recordings.map(item => Recording.parse(item));
2097
2106
  }
2098
2107
 
@@ -2194,6 +2203,10 @@ class CallLog {
2194
2203
  }
2195
2204
 
2196
2205
  static parseMany(plain ) {
2206
+ if (!plain || !plain.items) {
2207
+ return [];
2208
+ }
2209
+
2197
2210
  return plain.items.map(item => CallLog.parse(item));
2198
2211
  }
2199
2212
 
@@ -3533,6 +3546,9 @@ class Meeting {
3533
3546
  }
3534
3547
 
3535
3548
  static parseMany(items ) {
3549
+ if (!items) {
3550
+ return [];
3551
+ }
3536
3552
  return items.map(plain => Meeting.parse(plain));
3537
3553
  }
3538
3554
 
@@ -3692,6 +3708,10 @@ class ChatMessage {
3692
3708
 
3693
3709
 
3694
3710
  static parseMany(plain ) {
3711
+ if (!plain || !plain.items) {
3712
+ return [];
3713
+ }
3714
+
3695
3715
  return plain.items.map(item => ChatMessage.parse(item));
3696
3716
  }
3697
3717
 
@@ -3801,6 +3821,9 @@ class Voicemail {
3801
3821
  }
3802
3822
 
3803
3823
  static parseMany(plain ) {
3824
+ if (!plain) {
3825
+ return [];
3826
+ }
3804
3827
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3805
3828
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3806
3829
 
@@ -4184,6 +4207,9 @@ class ChatRoom {
4184
4207
 
4185
4208
 
4186
4209
  static parseMany(plain ) {
4210
+ if (!plain || !plain.items) {
4211
+ return [];
4212
+ }
4187
4213
  return plain.items.map(item => ChatRoom.parse(item));
4188
4214
  }
4189
4215
 
@@ -5368,6 +5394,10 @@ class CTIPhone extends Emitter {
5368
5394
  return false;
5369
5395
  }
5370
5396
 
5397
+ hasAVideoTrack() {
5398
+ return false;
5399
+ }
5400
+
5371
5401
  getLocalStreamForCall() {
5372
5402
  return null;
5373
5403
  }
@@ -1417,18 +1417,20 @@ class WebRTCPhone extends Emitter {
1417
1417
  screenTrack,
1418
1418
  });
1419
1419
 
1420
- screenTrack.onended = () => {
1421
- logger.info('WebRTC phone - on screenshare ended', {
1422
- hadVideo,
1423
- id: this.getSipSessionId(sipSession),
1424
- screenTrack,
1425
- });
1426
-
1427
- this.eventEmitter.emit(
1428
- ON_SHARE_SCREEN_ENDING,
1429
- this._createCallSession(sipSession, callSession),
1430
- );
1431
- };
1420
+ if (screenTrack) {
1421
+ screenTrack.onended = () => {
1422
+ logger.info('WebRTC phone - on screenshare ended', {
1423
+ hadVideo,
1424
+ id: this.getSipSessionId(sipSession),
1425
+ screenTrack,
1426
+ });
1427
+
1428
+ this.eventEmitter.emit(
1429
+ ON_SHARE_SCREEN_ENDING,
1430
+ this._createCallSession(sipSession, callSession),
1431
+ );
1432
+ };
1433
+ }
1432
1434
 
1433
1435
  this.currentScreenShare = {
1434
1436
  stream: screenStream,
@@ -26,6 +26,9 @@ class Recording {
26
26
 
27
27
 
28
28
  static parseMany(recordings = []) {
29
+ if (!recordings) {
30
+ return [];
31
+ }
29
32
  return recordings.map(item => Recording.parse(item));
30
33
  }
31
34
 
@@ -71,6 +71,9 @@ class Voicemail {
71
71
  }
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
75
78
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
76
79
 
@@ -71,6 +71,9 @@ class Call {
71
71
 
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  return plain.map((plainCall ) => Call.parse(plainCall));
75
78
  }
76
79
 
@@ -54,6 +54,9 @@ class Recording {
54
54
 
55
55
 
56
56
  static parseMany(recordings = []) {
57
+ if (!recordings) {
58
+ return [];
59
+ }
57
60
  return recordings.map(item => Recording.parse(item));
58
61
  }
59
62
 
@@ -155,6 +158,10 @@ class CallLog {
155
158
  }
156
159
 
157
160
  static parseMany(plain ) {
161
+ if (!plain || !plain.items) {
162
+ return [];
163
+ }
164
+
158
165
  return plain.items.map(item => CallLog.parse(item));
159
166
  }
160
167
 
@@ -325,6 +325,9 @@ class Contact {
325
325
  }
326
326
 
327
327
  static parseMany(response ) {
328
+ if (!response || !response.results) {
329
+ return [];
330
+ }
328
331
  return response.results.map(r => Contact.parse(r, response.column_types));
329
332
  }
330
333
 
@@ -71,6 +71,9 @@ class Voicemail {
71
71
  }
72
72
 
73
73
  static parseMany(plain ) {
74
+ if (!plain) {
75
+ return [];
76
+ }
74
77
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
75
78
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
76
79