@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
@@ -733,10 +733,6 @@ const getSrflxOrRelay = (candidates ) =>
733
733
  candidates
734
734
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
735
735
 
736
- const areCandidateValid = (candidates ) =>
737
- getSrflxOrRelay(candidates)
738
- .length > 0;
739
-
740
736
  const getVideoDirection = (sdp ) => {
741
737
  const parsedSdp = sdpParser__default['default'].parse(sdp);
742
738
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -789,8 +785,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
789
785
  /* global RTCSessionDescriptionInit, navigator */
790
786
 
791
787
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
792
- const MAX_WAIT_FOR_ICE_TRIES = 20;
793
- const WAIT_FOR_ICE_TIMEOUT = 500;
794
788
 
795
789
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
796
790
  const wazoMediaStreamFactory = (constraints ) => {
@@ -980,38 +974,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
980
974
  this._peerConnection = undefined;
981
975
  }
982
976
 
983
- async _waitForValidGatheredIce() {
984
- let tries = 0;
985
-
986
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
987
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
988
- tries,
989
- max: MAX_WAIT_FOR_ICE_TRIES,
990
- });
991
-
992
- tries++;
993
-
994
- // eslint-disable-next-line no-await-in-loop
995
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
996
- }
997
-
998
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
999
- const errorMsg = 'No valid candidates found, can\'t answer the call';
1000
- const error = new Error(errorMsg);
1001
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
1002
-
1003
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
1004
- this.eventEmitter.emit('error', error);
1005
-
1006
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
1007
- }
1008
-
1009
- // eslint-disable-next-line
1010
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
1011
-
1012
- return this.getLocalSessionDescription();
1013
- }
1014
-
1015
977
  // Overridden to send `inactive` in conference
1016
978
  updateDirection(options , isConference = false,
1017
979
  audioOnly = false) {
@@ -2121,6 +2083,9 @@ class Contact {
2121
2083
  }
2122
2084
 
2123
2085
  static parseMany(response ) {
2086
+ if (!response || !response.results) {
2087
+ return [];
2088
+ }
2124
2089
  return response.results.map(r => Contact.parse(r, response.column_types));
2125
2090
  }
2126
2091
 
@@ -3228,6 +3193,9 @@ class Meeting {
3228
3193
  }
3229
3194
 
3230
3195
  static parseMany(items ) {
3196
+ if (!items) {
3197
+ return [];
3198
+ }
3231
3199
  return items.map(plain => Meeting.parse(plain));
3232
3200
  }
3233
3201
 
@@ -3430,6 +3398,10 @@ class ChatMessage {
3430
3398
 
3431
3399
 
3432
3400
  static parseMany(plain ) {
3401
+ if (!plain || !plain.items) {
3402
+ return [];
3403
+ }
3404
+
3433
3405
  return plain.items.map(item => ChatMessage.parse(item));
3434
3406
  }
3435
3407
 
@@ -3539,6 +3511,9 @@ class Voicemail {
3539
3511
  }
3540
3512
 
3541
3513
  static parseMany(plain ) {
3514
+ if (!plain) {
3515
+ return [];
3516
+ }
3542
3517
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3543
3518
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3544
3519
 
@@ -3648,6 +3623,9 @@ class Call {
3648
3623
 
3649
3624
 
3650
3625
  static parseMany(plain ) {
3626
+ if (!plain) {
3627
+ return [];
3628
+ }
3651
3629
  return plain.map((plainCall ) => Call.parse(plainCall));
3652
3630
  }
3653
3631
 
@@ -3820,6 +3798,9 @@ class Recording {
3820
3798
 
3821
3799
 
3822
3800
  static parseMany(recordings = []) {
3801
+ if (!recordings) {
3802
+ return [];
3803
+ }
3823
3804
  return recordings.map(item => Recording.parse(item));
3824
3805
  }
3825
3806
 
@@ -3921,6 +3902,10 @@ class CallLog {
3921
3902
  }
3922
3903
 
3923
3904
  static parseMany(plain ) {
3905
+ if (!plain || !plain.items) {
3906
+ return [];
3907
+ }
3908
+
3924
3909
  return plain.items.map(item => CallLog.parse(item));
3925
3910
  }
3926
3911
 
@@ -4493,6 +4478,9 @@ class ChatRoom {
4493
4478
 
4494
4479
 
4495
4480
  static parseMany(plain ) {
4481
+ if (!plain || !plain.items) {
4482
+ return [];
4483
+ }
4496
4484
  return plain.items.map(item => ChatRoom.parse(item));
4497
4485
  }
4498
4486
 
@@ -7369,25 +7357,25 @@ class WebRTCClient extends Emitter {
7369
7357
 
7370
7358
  stats.forEach(report => {
7371
7359
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7372
- audioBytesSent += report.bytesSent + report.headerBytesSent;
7360
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7373
7361
  }
7374
7362
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7375
- audioBytesSent += report.bytesSent;
7363
+ audioBytesSent += Number(report.bytesSent);
7376
7364
  }
7377
7365
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7378
- videoBytesSent += report.bytesSent + report.headerBytesSent;
7366
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7379
7367
  }
7380
7368
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
7381
- packetsLost += report.packetsLost;
7382
- networkStats.packetsReceived = report.packetsReceived;
7383
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
7369
+ packetsLost += Number(report.packetsLost);
7370
+ networkStats.packetsReceived = Number(report.packetsReceived);
7371
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7384
7372
  }
7385
7373
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7386
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
7374
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7387
7375
  }
7388
7376
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7389
7377
  if ('framesPerSecond' in report) {
7390
- networkStats.framesPerSecond = report.framesPerSecond;
7378
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
7391
7379
  }
7392
7380
  if ('framerateMean' in report) {
7393
7381
  // framerateMean is only available in FF
@@ -7395,16 +7383,16 @@ class WebRTCClient extends Emitter {
7395
7383
  }
7396
7384
  }
7397
7385
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
7398
- packetsLost += report.packetsLost;
7399
- networkStats.roundTripTime = report.roundTripTime;
7400
- networkStats.jitter = report.jitter;
7386
+ packetsLost += Number(report.packetsLost);
7387
+ networkStats.roundTripTime = Number(report.roundTripTime);
7388
+ networkStats.jitter = Number(report.jitter);
7401
7389
  }
7402
7390
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
7403
- packetsLost += report.packetsLost;
7391
+ packetsLost += Number(report.packetsLost);
7404
7392
  }
7405
7393
  if (report.type === 'transport') {
7406
- transportSent += report.bytesSent;
7407
- transportReceived += report.bytesReceived;
7394
+ transportSent += Number(report.bytesSent);
7395
+ transportReceived += Number(report.bytesReceived);
7408
7396
  }
7409
7397
  });
7410
7398
 
@@ -450,6 +450,9 @@ class Recording {
450
450
 
451
451
 
452
452
  static parseMany(recordings = []) {
453
+ if (!recordings) {
454
+ return [];
455
+ }
453
456
  return recordings.map(item => Recording.parse(item));
454
457
  }
455
458
 
@@ -551,6 +554,10 @@ class CallLog {
551
554
  }
552
555
 
553
556
  static parseMany(plain ) {
557
+ if (!plain || !plain.items) {
558
+ return [];
559
+ }
560
+
554
561
  return plain.items.map(item => CallLog.parse(item));
555
562
  }
556
563
 
package/lib/api/calld.js CHANGED
@@ -790,6 +790,10 @@ class ChatMessage {
790
790
 
791
791
 
792
792
  static parseMany(plain ) {
793
+ if (!plain || !plain.items) {
794
+ return [];
795
+ }
796
+
793
797
  return plain.items.map(item => ChatMessage.parse(item));
794
798
  }
795
799
 
@@ -899,6 +903,9 @@ class Voicemail {
899
903
  }
900
904
 
901
905
  static parseMany(plain ) {
906
+ if (!plain) {
907
+ return [];
908
+ }
902
909
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
903
910
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
904
911
 
@@ -1008,6 +1015,9 @@ class Call {
1008
1015
 
1009
1016
 
1010
1017
  static parseMany(plain ) {
1018
+ if (!plain) {
1019
+ return [];
1020
+ }
1011
1021
  return plain.map((plainCall ) => Call.parse(plainCall));
1012
1022
  }
1013
1023
 
package/lib/api/chatd.js CHANGED
@@ -1109,6 +1109,9 @@ class ChatRoom {
1109
1109
 
1110
1110
 
1111
1111
  static parseMany(plain ) {
1112
+ if (!plain || !plain.items) {
1113
+ return [];
1114
+ }
1112
1115
  return plain.items.map(item => ChatRoom.parse(item));
1113
1116
  }
1114
1117
 
@@ -1175,6 +1178,10 @@ class ChatMessage {
1175
1178
 
1176
1179
 
1177
1180
  static parseMany(plain ) {
1181
+ if (!plain || !plain.items) {
1182
+ return [];
1183
+ }
1184
+
1178
1185
  return plain.items.map(item => ChatMessage.parse(item));
1179
1186
  }
1180
1187
 
package/lib/api/confd.js CHANGED
@@ -1318,6 +1318,9 @@ class Meeting {
1318
1318
  }
1319
1319
 
1320
1320
  static parseMany(items ) {
1321
+ if (!items) {
1322
+ return [];
1323
+ }
1321
1324
  return items.map(plain => Meeting.parse(plain));
1322
1325
  }
1323
1326
 
@@ -793,6 +793,10 @@ class ChatMessage {
793
793
 
794
794
 
795
795
  static parseMany(plain ) {
796
+ if (!plain || !plain.items) {
797
+ return [];
798
+ }
799
+
796
800
  return plain.items.map(item => ChatMessage.parse(item));
797
801
  }
798
802
 
@@ -902,6 +906,9 @@ class Voicemail {
902
906
  }
903
907
 
904
908
  static parseMany(plain ) {
909
+ if (!plain) {
910
+ return [];
911
+ }
905
912
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
906
913
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
907
914
 
@@ -1011,6 +1018,9 @@ class Call {
1011
1018
 
1012
1019
 
1013
1020
  static parseMany(plain ) {
1021
+ if (!plain) {
1022
+ return [];
1023
+ }
1014
1024
  return plain.map((plainCall ) => Call.parse(plainCall));
1015
1025
  }
1016
1026
 
package/lib/api/dird.js CHANGED
@@ -1021,6 +1021,9 @@ class Contact {
1021
1021
  }
1022
1022
 
1023
1023
  static parseMany(response ) {
1024
+ if (!response || !response.results) {
1025
+ return [];
1026
+ }
1024
1027
  return response.results.map(r => Contact.parse(r, response.column_types));
1025
1028
  }
1026
1029
 
package/lib/api-client.js CHANGED
@@ -1537,6 +1537,9 @@ class Contact {
1537
1537
  }
1538
1538
 
1539
1539
  static parseMany(response ) {
1540
+ if (!response || !response.results) {
1541
+ return [];
1542
+ }
1540
1543
  return response.results.map(r => Contact.parse(r, response.column_types));
1541
1544
  }
1542
1545
 
@@ -2644,6 +2647,9 @@ class Meeting {
2644
2647
  }
2645
2648
 
2646
2649
  static parseMany(items ) {
2650
+ if (!items) {
2651
+ return [];
2652
+ }
2647
2653
  return items.map(plain => Meeting.parse(plain));
2648
2654
  }
2649
2655
 
@@ -2846,6 +2852,10 @@ class ChatMessage {
2846
2852
 
2847
2853
 
2848
2854
  static parseMany(plain ) {
2855
+ if (!plain || !plain.items) {
2856
+ return [];
2857
+ }
2858
+
2849
2859
  return plain.items.map(item => ChatMessage.parse(item));
2850
2860
  }
2851
2861
 
@@ -2955,6 +2965,9 @@ class Voicemail {
2955
2965
  }
2956
2966
 
2957
2967
  static parseMany(plain ) {
2968
+ if (!plain) {
2969
+ return [];
2970
+ }
2958
2971
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2959
2972
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2960
2973
 
@@ -3064,6 +3077,9 @@ class Call {
3064
3077
 
3065
3078
 
3066
3079
  static parseMany(plain ) {
3080
+ if (!plain) {
3081
+ return [];
3082
+ }
3067
3083
  return plain.map((plainCall ) => Call.parse(plainCall));
3068
3084
  }
3069
3085
 
@@ -3236,6 +3252,9 @@ class Recording {
3236
3252
 
3237
3253
 
3238
3254
  static parseMany(recordings = []) {
3255
+ if (!recordings) {
3256
+ return [];
3257
+ }
3239
3258
  return recordings.map(item => Recording.parse(item));
3240
3259
  }
3241
3260
 
@@ -3337,6 +3356,10 @@ class CallLog {
3337
3356
  }
3338
3357
 
3339
3358
  static parseMany(plain ) {
3359
+ if (!plain || !plain.items) {
3360
+ return [];
3361
+ }
3362
+
3340
3363
  return plain.items.map(item => CallLog.parse(item));
3341
3364
  }
3342
3365
 
@@ -3909,6 +3932,9 @@ class ChatRoom {
3909
3932
 
3910
3933
 
3911
3934
  static parseMany(plain ) {
3935
+ if (!plain || !plain.items) {
3936
+ return [];
3937
+ }
3912
3938
  return plain.items.map(item => ChatRoom.parse(item));
3913
3939
  }
3914
3940
 
@@ -1559,6 +1559,9 @@ class Contact {
1559
1559
  }
1560
1560
 
1561
1561
  static parseMany(response ) {
1562
+ if (!response || !response.results) {
1563
+ return [];
1564
+ }
1562
1565
  return response.results.map(r => Contact.parse(r, response.column_types));
1563
1566
  }
1564
1567
 
@@ -2666,6 +2669,9 @@ class Meeting {
2666
2669
  }
2667
2670
 
2668
2671
  static parseMany(items ) {
2672
+ if (!items) {
2673
+ return [];
2674
+ }
2669
2675
  return items.map(plain => Meeting.parse(plain));
2670
2676
  }
2671
2677
 
@@ -2868,6 +2874,10 @@ class ChatMessage {
2868
2874
 
2869
2875
 
2870
2876
  static parseMany(plain ) {
2877
+ if (!plain || !plain.items) {
2878
+ return [];
2879
+ }
2880
+
2871
2881
  return plain.items.map(item => ChatMessage.parse(item));
2872
2882
  }
2873
2883
 
@@ -2977,6 +2987,9 @@ class Voicemail {
2977
2987
  }
2978
2988
 
2979
2989
  static parseMany(plain ) {
2990
+ if (!plain) {
2991
+ return [];
2992
+ }
2980
2993
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2981
2994
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2982
2995
 
@@ -3086,6 +3099,9 @@ class Call {
3086
3099
 
3087
3100
 
3088
3101
  static parseMany(plain ) {
3102
+ if (!plain) {
3103
+ return [];
3104
+ }
3089
3105
  return plain.map((plainCall ) => Call.parse(plainCall));
3090
3106
  }
3091
3107
 
@@ -3284,6 +3300,9 @@ class Recording {
3284
3300
 
3285
3301
 
3286
3302
  static parseMany(recordings = []) {
3303
+ if (!recordings) {
3304
+ return [];
3305
+ }
3287
3306
  return recordings.map(item => Recording.parse(item));
3288
3307
  }
3289
3308
 
@@ -3385,6 +3404,10 @@ class CallLog {
3385
3404
  }
3386
3405
 
3387
3406
  static parseMany(plain ) {
3407
+ if (!plain || !plain.items) {
3408
+ return [];
3409
+ }
3410
+
3388
3411
  return plain.items.map(item => CallLog.parse(item));
3389
3412
  }
3390
3413
 
@@ -3957,6 +3980,9 @@ class ChatRoom {
3957
3980
 
3958
3981
 
3959
3982
  static parseMany(plain ) {
3983
+ if (!plain || !plain.items) {
3984
+ return [];
3985
+ }
3960
3986
  return plain.items.map(item => ChatRoom.parse(item));
3961
3987
  }
3962
3988
 
@@ -5359,10 +5385,6 @@ const getSrflxOrRelay = (candidates ) =>
5359
5385
  candidates
5360
5386
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5361
5387
 
5362
- const areCandidateValid = (candidates ) =>
5363
- getSrflxOrRelay(candidates)
5364
- .length > 0;
5365
-
5366
5388
  const getVideoDirection = (sdp ) => {
5367
5389
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5368
5390
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5415,8 +5437,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5415
5437
  /* global RTCSessionDescriptionInit, navigator */
5416
5438
 
5417
5439
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5418
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5419
- const WAIT_FOR_ICE_TIMEOUT = 500;
5420
5440
 
5421
5441
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5422
5442
  const wazoMediaStreamFactory = (constraints ) => {
@@ -5606,38 +5626,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5606
5626
  this._peerConnection = undefined;
5607
5627
  }
5608
5628
 
5609
- async _waitForValidGatheredIce() {
5610
- let tries = 0;
5611
-
5612
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
5613
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
5614
- tries,
5615
- max: MAX_WAIT_FOR_ICE_TRIES,
5616
- });
5617
-
5618
- tries++;
5619
-
5620
- // eslint-disable-next-line no-await-in-loop
5621
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
5622
- }
5623
-
5624
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
5625
- const errorMsg = 'No valid candidates found, can\'t answer the call';
5626
- const error = new Error(errorMsg);
5627
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
5628
-
5629
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
5630
- this.eventEmitter.emit('error', error);
5631
-
5632
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5633
- }
5634
-
5635
- // eslint-disable-next-line
5636
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5637
-
5638
- return this.getLocalSessionDescription();
5639
- }
5640
-
5641
5629
  // Overridden to send `inactive` in conference
5642
5630
  updateDirection(options , isConference = false,
5643
5631
  audioOnly = false) {
@@ -7955,25 +7943,25 @@ class WebRTCClient extends Emitter {
7955
7943
 
7956
7944
  stats.forEach(report => {
7957
7945
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
7958
- audioBytesSent += report.bytesSent + report.headerBytesSent;
7946
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7959
7947
  }
7960
7948
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
7961
- audioBytesSent += report.bytesSent;
7949
+ audioBytesSent += Number(report.bytesSent);
7962
7950
  }
7963
7951
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7964
- videoBytesSent += report.bytesSent + report.headerBytesSent;
7952
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
7965
7953
  }
7966
7954
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
7967
- packetsLost += report.packetsLost;
7968
- networkStats.packetsReceived = report.packetsReceived;
7969
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
7955
+ packetsLost += Number(report.packetsLost);
7956
+ networkStats.packetsReceived = Number(report.packetsReceived);
7957
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7970
7958
  }
7971
7959
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
7972
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
7960
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
7973
7961
  }
7974
7962
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
7975
7963
  if ('framesPerSecond' in report) {
7976
- networkStats.framesPerSecond = report.framesPerSecond;
7964
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
7977
7965
  }
7978
7966
  if ('framerateMean' in report) {
7979
7967
  // framerateMean is only available in FF
@@ -7981,16 +7969,16 @@ class WebRTCClient extends Emitter {
7981
7969
  }
7982
7970
  }
7983
7971
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
7984
- packetsLost += report.packetsLost;
7985
- networkStats.roundTripTime = report.roundTripTime;
7986
- networkStats.jitter = report.jitter;
7972
+ packetsLost += Number(report.packetsLost);
7973
+ networkStats.roundTripTime = Number(report.roundTripTime);
7974
+ networkStats.jitter = Number(report.jitter);
7987
7975
  }
7988
7976
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
7989
- packetsLost += report.packetsLost;
7977
+ packetsLost += Number(report.packetsLost);
7990
7978
  }
7991
7979
  if (report.type === 'transport') {
7992
- transportSent += report.bytesSent;
7993
- transportReceived += report.bytesReceived;
7980
+ transportSent += Number(report.bytesSent);
7981
+ transportReceived += Number(report.bytesReceived);
7994
7982
  }
7995
7983
  });
7996
7984
 
@@ -1537,6 +1537,9 @@ class Contact {
1537
1537
  }
1538
1538
 
1539
1539
  static parseMany(response ) {
1540
+ if (!response || !response.results) {
1541
+ return [];
1542
+ }
1540
1543
  return response.results.map(r => Contact.parse(r, response.column_types));
1541
1544
  }
1542
1545
 
@@ -2644,6 +2647,9 @@ class Meeting {
2644
2647
  }
2645
2648
 
2646
2649
  static parseMany(items ) {
2650
+ if (!items) {
2651
+ return [];
2652
+ }
2647
2653
  return items.map(plain => Meeting.parse(plain));
2648
2654
  }
2649
2655
 
@@ -2846,6 +2852,10 @@ class ChatMessage {
2846
2852
 
2847
2853
 
2848
2854
  static parseMany(plain ) {
2855
+ if (!plain || !plain.items) {
2856
+ return [];
2857
+ }
2858
+
2849
2859
  return plain.items.map(item => ChatMessage.parse(item));
2850
2860
  }
2851
2861
 
@@ -2955,6 +2965,9 @@ class Voicemail {
2955
2965
  }
2956
2966
 
2957
2967
  static parseMany(plain ) {
2968
+ if (!plain) {
2969
+ return [];
2970
+ }
2958
2971
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2959
2972
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2960
2973
 
@@ -3064,6 +3077,9 @@ class Call {
3064
3077
 
3065
3078
 
3066
3079
  static parseMany(plain ) {
3080
+ if (!plain) {
3081
+ return [];
3082
+ }
3067
3083
  return plain.map((plainCall ) => Call.parse(plainCall));
3068
3084
  }
3069
3085
 
@@ -3236,6 +3252,9 @@ class Recording {
3236
3252
 
3237
3253
 
3238
3254
  static parseMany(recordings = []) {
3255
+ if (!recordings) {
3256
+ return [];
3257
+ }
3239
3258
  return recordings.map(item => Recording.parse(item));
3240
3259
  }
3241
3260
 
@@ -3337,6 +3356,10 @@ class CallLog {
3337
3356
  }
3338
3357
 
3339
3358
  static parseMany(plain ) {
3359
+ if (!plain || !plain.items) {
3360
+ return [];
3361
+ }
3362
+
3340
3363
  return plain.items.map(item => CallLog.parse(item));
3341
3364
  }
3342
3365
 
@@ -3909,6 +3932,9 @@ class ChatRoom {
3909
3932
 
3910
3933
 
3911
3934
  static parseMany(plain ) {
3935
+ if (!plain || !plain.items) {
3936
+ return [];
3937
+ }
3912
3938
  return plain.items.map(item => ChatRoom.parse(item));
3913
3939
  }
3914
3940