@wazo/sdk 0.37.21 → 0.37.25

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 (118) hide show
  1. package/dist/wazo-sdk.js +5 -5
  2. package/esm/__tests__/api-client.test.js +36 -5
  3. package/esm/__tests__/web-rtc-client.test.js +77 -66
  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 +13 -5
  8. package/esm/api/ctid-ng.js +10 -0
  9. package/esm/api/dird.js +3 -0
  10. package/esm/api-client.js +36 -5
  11. package/esm/checker/Checker.js +77 -66
  12. package/esm/checker/checks/aor.js +36 -5
  13. package/esm/checker/checks/api.js +36 -5
  14. package/esm/checker/checks/index.js +77 -66
  15. package/esm/checker/checks/webrtc-transport.js +77 -66
  16. package/esm/checker/checks/webrtc.js +77 -66
  17. package/esm/domain/AdHocAPIConference.js +36 -5
  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 +36 -5
  24. package/esm/domain/Meeting.js +15 -5
  25. package/esm/domain/Phone/CTIPhone.js +40 -5
  26. package/esm/domain/Phone/WebRTCPhone.js +45 -16
  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__/Meeting.test.js +144 -0
  33. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  34. package/esm/index.js +125 -81
  35. package/esm/lib/WazoSessionDescriptionHandler.js +0 -38
  36. package/esm/service/CallApi.js +36 -5
  37. package/esm/service/getApiClient.js +36 -5
  38. package/esm/simple/Auth.js +125 -81
  39. package/esm/simple/Configuration.js +125 -81
  40. package/esm/simple/Directory.js +36 -5
  41. package/esm/simple/Phone.js +125 -81
  42. package/esm/simple/index.js +125 -81
  43. package/esm/simple/room/LocalParticipant.js +125 -81
  44. package/esm/simple/room/Participant.js +125 -81
  45. package/esm/simple/room/RemoteParticipant.js +125 -81
  46. package/esm/simple/room/Room.js +125 -81
  47. package/esm/simple/room/SipRoom.js +125 -81
  48. package/esm/simple/room/Stream.js +125 -81
  49. package/esm/simple/room/__tests__/RemoteParticipant.test.js +125 -81
  50. package/esm/simple/utils.js +125 -81
  51. package/esm/types/WebSocketMessage.js +1 -1
  52. package/esm/web-rtc-client.js +77 -66
  53. package/lib/__tests__/api-client.test.js +36 -5
  54. package/lib/__tests__/web-rtc-client.test.js +77 -66
  55. package/lib/api/call-logd.js +7 -0
  56. package/lib/api/calld.js +10 -0
  57. package/lib/api/chatd.js +7 -0
  58. package/lib/api/confd.js +13 -5
  59. package/lib/api/ctid-ng.js +10 -0
  60. package/lib/api/dird.js +3 -0
  61. package/lib/api-client.js +36 -5
  62. package/lib/checker/Checker.js +77 -66
  63. package/lib/checker/checks/aor.js +36 -5
  64. package/lib/checker/checks/api.js +36 -5
  65. package/lib/checker/checks/index.js +77 -66
  66. package/lib/checker/checks/webrtc-transport.js +77 -66
  67. package/lib/checker/checks/webrtc.js +77 -66
  68. package/lib/domain/AdHocAPIConference.js +36 -5
  69. package/lib/domain/Call.js +3 -0
  70. package/lib/domain/CallLog.js +7 -0
  71. package/lib/domain/ChatMessage.js +4 -0
  72. package/lib/domain/ChatRoom.js +3 -0
  73. package/lib/domain/Contact.js +3 -0
  74. package/lib/domain/Features.js +36 -5
  75. package/lib/domain/Meeting.js +19 -5
  76. package/lib/domain/Phone/CTIPhone.js +40 -5
  77. package/lib/domain/Phone/WebRTCPhone.js +45 -16
  78. package/lib/domain/Recording.js +3 -0
  79. package/lib/domain/Voicemail.js +3 -0
  80. package/lib/domain/__tests__/Call.test.js +3 -0
  81. package/lib/domain/__tests__/CallLog.test.js +7 -0
  82. package/lib/domain/__tests__/Contact.test.js +3 -0
  83. package/lib/domain/__tests__/Meeting.test.js +150 -0
  84. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  85. package/lib/index.js +125 -81
  86. package/lib/lib/WazoSessionDescriptionHandler.js +0 -38
  87. package/lib/service/CallApi.js +36 -5
  88. package/lib/service/getApiClient.js +36 -5
  89. package/lib/simple/Auth.js +125 -81
  90. package/lib/simple/Configuration.js +125 -81
  91. package/lib/simple/Directory.js +36 -5
  92. package/lib/simple/Phone.js +125 -81
  93. package/lib/simple/index.js +125 -81
  94. package/lib/simple/room/LocalParticipant.js +125 -81
  95. package/lib/simple/room/Participant.js +125 -81
  96. package/lib/simple/room/RemoteParticipant.js +125 -81
  97. package/lib/simple/room/Room.js +125 -81
  98. package/lib/simple/room/SipRoom.js +125 -81
  99. package/lib/simple/room/Stream.js +125 -81
  100. package/lib/simple/room/__tests__/RemoteParticipant.test.js +125 -81
  101. package/lib/simple/utils.js +125 -81
  102. package/lib/types/WebSocketMessage.js +2 -0
  103. package/lib/web-rtc-client.js +77 -66
  104. package/package.json +1 -1
  105. package/src/domain/Call.js +3 -0
  106. package/src/domain/CallLog.js +4 -0
  107. package/src/domain/ChatMessage.js +4 -0
  108. package/src/domain/ChatRoom.js +3 -0
  109. package/src/domain/Contact.js +3 -0
  110. package/src/domain/Meeting.js +15 -5
  111. package/src/domain/Phone/CTIPhone.js +4 -0
  112. package/src/domain/Phone/Phone.js +2 -0
  113. package/src/domain/Phone/WebRTCPhone.js +45 -16
  114. package/src/domain/Recording.js +3 -0
  115. package/src/domain/Voicemail.js +3 -0
  116. package/src/domain/__tests__/Meeting.test.js +50 -0
  117. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  118. package/src/web-rtc-client.js +41 -23
@@ -409,10 +409,6 @@ const getSrflxOrRelay = (candidates ) =>
409
409
  candidates
410
410
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
411
411
 
412
- const areCandidateValid = (candidates ) =>
413
- getSrflxOrRelay(candidates)
414
- .length > 0;
415
-
416
412
  const fixSdp = (sdp , candidates , forcePort = true) => {
417
413
  const parsedSdp = sdpParser.parse(sdp);
418
414
  const mainCandidate = getSrflxOrRelay(candidates)[0];
@@ -444,8 +440,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
444
440
  /* global RTCSessionDescriptionInit, navigator */
445
441
 
446
442
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
447
- const MAX_WAIT_FOR_ICE_TRIES = 20;
448
- const WAIT_FOR_ICE_TIMEOUT = 500;
449
443
 
450
444
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
451
445
  const wazoMediaStreamFactory = (constraints ) => {
@@ -635,38 +629,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
635
629
  this._peerConnection = undefined;
636
630
  }
637
631
 
638
- async _waitForValidGatheredIce() {
639
- let tries = 0;
640
-
641
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
642
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
643
- tries,
644
- max: MAX_WAIT_FOR_ICE_TRIES,
645
- });
646
-
647
- tries++;
648
-
649
- // eslint-disable-next-line no-await-in-loop
650
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
651
- }
652
-
653
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
654
- const errorMsg = 'No valid candidates found, can\'t answer the call';
655
- const error = new Error(errorMsg);
656
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
657
-
658
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
659
- this.eventEmitter.emit('error', error);
660
-
661
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
662
- }
663
-
664
- // eslint-disable-next-line
665
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
666
-
667
- return this.getLocalSessionDescription();
668
- }
669
-
670
632
  // Overridden to send `inactive` in conference
671
633
  updateDirection(options , isConference = false,
672
634
  audioOnly = false) {
@@ -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
 
@@ -1034,6 +1037,9 @@ class Contact {
1034
1037
  }
1035
1038
 
1036
1039
  static parseMany(response ) {
1040
+ if (!response || !response.results) {
1041
+ return [];
1042
+ }
1037
1043
  return response.results.map(r => Contact.parse(r, response.column_types));
1038
1044
  }
1039
1045
 
@@ -1706,6 +1712,9 @@ class Recording {
1706
1712
 
1707
1713
 
1708
1714
  static parseMany(recordings = []) {
1715
+ if (!recordings) {
1716
+ return [];
1717
+ }
1709
1718
  return recordings.map(item => Recording.parse(item));
1710
1719
  }
1711
1720
 
@@ -1807,6 +1816,10 @@ class CallLog {
1807
1816
  }
1808
1817
 
1809
1818
  static parseMany(plain ) {
1819
+ if (!plain || !plain.items) {
1820
+ return [];
1821
+ }
1822
+
1810
1823
  return plain.items.map(item => CallLog.parse(item));
1811
1824
  }
1812
1825
 
@@ -3132,8 +3145,9 @@ class ExternalApp {
3132
3145
 
3133
3146
 
3134
3147
 
3135
-
3148
+
3136
3149
 
3150
+
3137
3151
 
3138
3152
 
3139
3153
  class Meeting {
@@ -3144,9 +3158,10 @@ class Meeting {
3144
3158
 
3145
3159
 
3146
3160
 
3147
-
3161
+
3148
3162
 
3149
3163
 
3164
+
3150
3165
 
3151
3166
  static parse(plain ) {
3152
3167
  return new Meeting({
@@ -3156,12 +3171,16 @@ class Meeting {
3156
3171
  ownerUuids: plain.owner_uuids,
3157
3172
  port: plain.port,
3158
3173
  uuid: plain.uuid,
3159
- number: plain.number,
3174
+ extension: plain.exten,
3160
3175
  persistent: plain.persistent,
3176
+ creationTime: moment(plain.creation_time).toDate(),
3161
3177
  });
3162
3178
  }
3163
3179
 
3164
3180
  static parseMany(items ) {
3181
+ if (!items) {
3182
+ return [];
3183
+ }
3165
3184
  return items.map(plain => Meeting.parse(plain));
3166
3185
  }
3167
3186
 
@@ -3176,8 +3195,9 @@ class Meeting {
3176
3195
  ownerUuids,
3177
3196
  port,
3178
3197
  uri,
3179
- number,
3198
+ extension,
3180
3199
  persistent,
3200
+ creationTime,
3181
3201
  } = {}) {
3182
3202
  this.guestSipAuthorization = guestSipAuthorization;
3183
3203
  this.uri = uri;
@@ -3185,8 +3205,9 @@ class Meeting {
3185
3205
  this.ownerUuids = ownerUuids;
3186
3206
  this.port = port;
3187
3207
  this.uuid = uuid;
3188
- this.number = number;
3208
+ this.extension = extension;
3189
3209
  this.persistent = persistent;
3210
+ this.creationTime = creationTime;
3190
3211
 
3191
3212
  // Useful to compare instead of instanceof with minified code
3192
3213
  this.type = 'Meeting';
@@ -3321,6 +3342,10 @@ class ChatMessage {
3321
3342
 
3322
3343
 
3323
3344
  static parseMany(plain ) {
3345
+ if (!plain || !plain.items) {
3346
+ return [];
3347
+ }
3348
+
3324
3349
  return plain.items.map(item => ChatMessage.parse(item));
3325
3350
  }
3326
3351
 
@@ -3430,6 +3455,9 @@ class Voicemail {
3430
3455
  }
3431
3456
 
3432
3457
  static parseMany(plain ) {
3458
+ if (!plain) {
3459
+ return [];
3460
+ }
3433
3461
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
3434
3462
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
3435
3463
 
@@ -3820,6 +3848,9 @@ class ChatRoom {
3820
3848
 
3821
3849
 
3822
3850
  static parseMany(plain ) {
3851
+ if (!plain || !plain.items) {
3852
+ return [];
3853
+ }
3823
3854
  return plain.items.map(item => ChatRoom.parse(item));
3824
3855
  }
3825
3856
 
@@ -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
 
@@ -2608,8 +2611,9 @@ class ExternalApp {
2608
2611
 
2609
2612
 
2610
2613
 
2611
-
2614
+
2612
2615
 
2616
+
2613
2617
 
2614
2618
 
2615
2619
  class Meeting {
@@ -2620,9 +2624,10 @@ class Meeting {
2620
2624
 
2621
2625
 
2622
2626
 
2623
-
2627
+
2624
2628
 
2625
2629
 
2630
+
2626
2631
 
2627
2632
  static parse(plain ) {
2628
2633
  return new Meeting({
@@ -2632,12 +2637,16 @@ class Meeting {
2632
2637
  ownerUuids: plain.owner_uuids,
2633
2638
  port: plain.port,
2634
2639
  uuid: plain.uuid,
2635
- number: plain.number,
2640
+ extension: plain.exten,
2636
2641
  persistent: plain.persistent,
2642
+ creationTime: moment(plain.creation_time).toDate(),
2637
2643
  });
2638
2644
  }
2639
2645
 
2640
2646
  static parseMany(items ) {
2647
+ if (!items) {
2648
+ return [];
2649
+ }
2641
2650
  return items.map(plain => Meeting.parse(plain));
2642
2651
  }
2643
2652
 
@@ -2652,8 +2661,9 @@ class Meeting {
2652
2661
  ownerUuids,
2653
2662
  port,
2654
2663
  uri,
2655
- number,
2664
+ extension,
2656
2665
  persistent,
2666
+ creationTime,
2657
2667
  } = {}) {
2658
2668
  this.guestSipAuthorization = guestSipAuthorization;
2659
2669
  this.uri = uri;
@@ -2661,8 +2671,9 @@ class Meeting {
2661
2671
  this.ownerUuids = ownerUuids;
2662
2672
  this.port = port;
2663
2673
  this.uuid = uuid;
2664
- this.number = number;
2674
+ this.extension = extension;
2665
2675
  this.persistent = persistent;
2676
+ this.creationTime = creationTime;
2666
2677
 
2667
2678
  // Useful to compare instead of instanceof with minified code
2668
2679
  this.type = 'Meeting';
@@ -2840,6 +2851,10 @@ class ChatMessage {
2840
2851
 
2841
2852
 
2842
2853
  static parseMany(plain ) {
2854
+ if (!plain || !plain.items) {
2855
+ return [];
2856
+ }
2857
+
2843
2858
  return plain.items.map(item => ChatMessage.parse(item));
2844
2859
  }
2845
2860
 
@@ -2949,6 +2964,9 @@ class Voicemail {
2949
2964
  }
2950
2965
 
2951
2966
  static parseMany(plain ) {
2967
+ if (!plain) {
2968
+ return [];
2969
+ }
2952
2970
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2953
2971
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2954
2972
 
@@ -3058,6 +3076,9 @@ class Call {
3058
3076
 
3059
3077
 
3060
3078
  static parseMany(plain ) {
3079
+ if (!plain) {
3080
+ return [];
3081
+ }
3061
3082
  return plain.map((plainCall ) => Call.parse(plainCall));
3062
3083
  }
3063
3084
 
@@ -3230,6 +3251,9 @@ class Recording {
3230
3251
 
3231
3252
 
3232
3253
  static parseMany(recordings = []) {
3254
+ if (!recordings) {
3255
+ return [];
3256
+ }
3233
3257
  return recordings.map(item => Recording.parse(item));
3234
3258
  }
3235
3259
 
@@ -3331,6 +3355,10 @@ class CallLog {
3331
3355
  }
3332
3356
 
3333
3357
  static parseMany(plain ) {
3358
+ if (!plain || !plain.items) {
3359
+ return [];
3360
+ }
3361
+
3334
3362
  return plain.items.map(item => CallLog.parse(item));
3335
3363
  }
3336
3364
 
@@ -3888,6 +3916,9 @@ class ChatRoom {
3888
3916
 
3889
3917
 
3890
3918
  static parseMany(plain ) {
3919
+ if (!plain || !plain.items) {
3920
+ return [];
3921
+ }
3891
3922
  return plain.items.map(item => ChatRoom.parse(item));
3892
3923
  }
3893
3924