@wazo/sdk 0.37.20 → 0.37.24

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 (147) hide show
  1. package/dist/wazo-sdk.js +6 -6
  2. package/esm/__tests__/api-client.test.js +91 -21
  3. package/esm/__tests__/web-rtc-client.test.js +214 -165
  4. package/esm/api/agentd.js +25 -2
  5. package/esm/api/amid.js +26 -3
  6. package/esm/api/application.js +25 -2
  7. package/esm/api/auth.js +25 -2
  8. package/esm/api/call-logd.js +34 -4
  9. package/esm/api/calld.js +35 -2
  10. package/esm/api/chatd.js +32 -2
  11. package/esm/api/confd.js +56 -9
  12. package/esm/api/ctid-ng.js +38 -5
  13. package/esm/api/dird.js +29 -3
  14. package/esm/api/webhookd.js +26 -3
  15. package/esm/api-client.js +91 -21
  16. package/esm/checker/Checker.js +241 -190
  17. package/esm/checker/checks/aor.js +91 -21
  18. package/esm/checker/checks/api.js +91 -21
  19. package/esm/checker/checks/index.js +231 -180
  20. package/esm/checker/checks/wazo-websocket.js +42 -17
  21. package/esm/checker/checks/webrtc-transport.js +214 -165
  22. package/esm/checker/checks/webrtc.js +214 -165
  23. package/esm/domain/AdHocAPIConference.js +91 -21
  24. package/esm/domain/Call.js +3 -0
  25. package/esm/domain/CallLog.js +8 -1
  26. package/esm/domain/ChatMessage.js +4 -0
  27. package/esm/domain/ChatRoom.js +3 -0
  28. package/esm/domain/Contact.js +4 -1
  29. package/esm/domain/Features.js +91 -21
  30. package/esm/domain/Meeting.js +28 -5
  31. package/esm/domain/Phone/CTIPhone.js +109 -35
  32. package/esm/domain/Phone/WebRTCPhone.js +159 -102
  33. package/esm/domain/Recording.js +3 -0
  34. package/esm/domain/Voicemail.js +3 -0
  35. package/esm/domain/__tests__/Call.test.js +3 -0
  36. package/esm/domain/__tests__/CallLog.test.js +8 -1
  37. package/esm/domain/__tests__/Contact.test.js +4 -1
  38. package/esm/domain/__tests__/Meeting.test.js +144 -0
  39. package/esm/domain/__tests__/Voicemail.test.js +3 -0
  40. package/esm/index.js +509 -414
  41. package/esm/lib/WazoSessionDescriptionHandler.js +26 -41
  42. package/esm/service/CallApi.js +91 -21
  43. package/esm/service/IssueReporter.js +26 -3
  44. package/esm/service/__tests__/IssueReporter.test.js +26 -3
  45. package/esm/service/getApiClient.js +91 -21
  46. package/esm/simple/Auth.js +499 -404
  47. package/esm/simple/Configuration.js +499 -404
  48. package/esm/simple/Directory.js +91 -21
  49. package/esm/simple/Phone.js +499 -404
  50. package/esm/simple/Websocket.js +45 -19
  51. package/esm/simple/index.js +503 -408
  52. package/esm/simple/room/LocalParticipant.js +503 -408
  53. package/esm/simple/room/Participant.js +503 -408
  54. package/esm/simple/room/RemoteParticipant.js +503 -408
  55. package/esm/simple/room/Room.js +504 -409
  56. package/esm/simple/room/SipRoom.js +503 -408
  57. package/esm/simple/room/Stream.js +503 -408
  58. package/esm/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  59. package/esm/simple/utils.js +503 -408
  60. package/esm/types/WebSocketMessage.js +1 -1
  61. package/esm/utils/__tests__/api-requester.test.js +25 -2
  62. package/esm/utils/api-requester.js +25 -2
  63. package/esm/web-rtc-client.js +214 -165
  64. package/esm/websocket-client.js +43 -18
  65. package/lib/__tests__/api-client.test.js +91 -21
  66. package/lib/__tests__/web-rtc-client.test.js +214 -165
  67. package/lib/api/agentd.js +25 -2
  68. package/lib/api/amid.js +26 -3
  69. package/lib/api/application.js +25 -2
  70. package/lib/api/auth.js +25 -2
  71. package/lib/api/call-logd.js +34 -4
  72. package/lib/api/calld.js +35 -2
  73. package/lib/api/chatd.js +32 -2
  74. package/lib/api/confd.js +56 -9
  75. package/lib/api/ctid-ng.js +38 -5
  76. package/lib/api/dird.js +29 -3
  77. package/lib/api/webhookd.js +26 -3
  78. package/lib/api-client.js +91 -21
  79. package/lib/checker/Checker.js +241 -190
  80. package/lib/checker/checks/aor.js +91 -21
  81. package/lib/checker/checks/api.js +91 -21
  82. package/lib/checker/checks/index.js +231 -180
  83. package/lib/checker/checks/wazo-websocket.js +42 -17
  84. package/lib/checker/checks/webrtc-transport.js +214 -165
  85. package/lib/checker/checks/webrtc.js +214 -165
  86. package/lib/domain/AdHocAPIConference.js +91 -21
  87. package/lib/domain/Call.js +3 -0
  88. package/lib/domain/CallLog.js +8 -1
  89. package/lib/domain/ChatMessage.js +4 -0
  90. package/lib/domain/ChatRoom.js +3 -0
  91. package/lib/domain/Contact.js +4 -1
  92. package/lib/domain/Features.js +91 -21
  93. package/lib/domain/Meeting.js +32 -5
  94. package/lib/domain/Phone/CTIPhone.js +109 -35
  95. package/lib/domain/Phone/WebRTCPhone.js +159 -102
  96. package/lib/domain/Recording.js +3 -0
  97. package/lib/domain/Voicemail.js +3 -0
  98. package/lib/domain/__tests__/Call.test.js +3 -0
  99. package/lib/domain/__tests__/CallLog.test.js +8 -1
  100. package/lib/domain/__tests__/Contact.test.js +4 -1
  101. package/lib/domain/__tests__/Meeting.test.js +150 -0
  102. package/lib/domain/__tests__/Voicemail.test.js +3 -0
  103. package/lib/index.js +509 -414
  104. package/lib/lib/WazoSessionDescriptionHandler.js +26 -41
  105. package/lib/service/CallApi.js +91 -21
  106. package/lib/service/IssueReporter.js +26 -3
  107. package/lib/service/__tests__/IssueReporter.test.js +26 -3
  108. package/lib/service/getApiClient.js +91 -21
  109. package/lib/simple/Auth.js +499 -404
  110. package/lib/simple/Configuration.js +499 -404
  111. package/lib/simple/Directory.js +91 -21
  112. package/lib/simple/Phone.js +499 -404
  113. package/lib/simple/Websocket.js +45 -19
  114. package/lib/simple/index.js +503 -408
  115. package/lib/simple/room/LocalParticipant.js +503 -408
  116. package/lib/simple/room/Participant.js +503 -408
  117. package/lib/simple/room/RemoteParticipant.js +503 -408
  118. package/lib/simple/room/Room.js +504 -409
  119. package/lib/simple/room/SipRoom.js +503 -408
  120. package/lib/simple/room/Stream.js +503 -408
  121. package/lib/simple/room/__tests__/RemoteParticipant.test.js +503 -408
  122. package/lib/simple/utils.js +503 -408
  123. package/lib/types/WebSocketMessage.js +2 -0
  124. package/lib/utils/__tests__/api-requester.test.js +25 -2
  125. package/lib/utils/api-requester.js +25 -2
  126. package/lib/web-rtc-client.js +214 -165
  127. package/lib/websocket-client.js +43 -17
  128. package/package.json +1 -1
  129. package/src/api/confd.js +5 -2
  130. package/src/domain/Call.js +3 -0
  131. package/src/domain/CallLog.js +4 -0
  132. package/src/domain/ChatMessage.js +4 -0
  133. package/src/domain/ChatRoom.js +3 -0
  134. package/src/domain/Contact.js +3 -0
  135. package/src/domain/Meeting.js +28 -5
  136. package/src/domain/Phone/CTIPhone.js +4 -0
  137. package/src/domain/Phone/Phone.js +2 -0
  138. package/src/domain/Phone/WebRTCPhone.js +49 -15
  139. package/src/domain/Recording.js +3 -0
  140. package/src/domain/Voicemail.js +3 -0
  141. package/src/domain/__tests__/Meeting.test.js +50 -0
  142. package/src/lib/WazoSessionDescriptionHandler.js +1 -35
  143. package/src/service/IssueReporter.js +25 -2
  144. package/src/simple/Phone.js +5 -0
  145. package/src/types/WebSocketMessage.js +5 -1
  146. package/src/web-rtc-client.js +41 -24
  147. package/src/websocket-client.js +2 -0
package/esm/index.js CHANGED
@@ -150,6 +150,7 @@ class IssueReporter {
150
150
 
151
151
 
152
152
 
153
+
153
154
 
154
155
  constructor() {
155
156
  addLevelsTo(this);
@@ -161,12 +162,17 @@ class IssueReporter {
161
162
  this.bufferTimeout = null;
162
163
  this._boundProcessBuffer = this._processBuffer.bind(this);
163
164
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
165
+ this._callback = null;
164
166
  }
165
167
 
166
168
  init() {
167
169
  this._catchConsole();
168
170
  }
169
171
 
172
+ setCallback(cb ) {
173
+ this._callback = cb;
174
+ }
175
+
170
176
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
171
177
  this.remoteClientConfiguration = configuration;
172
178
  }
@@ -202,6 +208,7 @@ class IssueReporter {
202
208
 
203
209
  // Handle category label
204
210
  let category = null;
211
+ let skipSendToRemote = false;
205
212
  let extra = {};
206
213
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
207
214
  category = args[0].split('=')[1];
@@ -217,6 +224,7 @@ class IssueReporter {
217
224
  errorMessage: lastArg.message,
218
225
  errorStack: lastArg.stack,
219
226
  errorType: lastArg.constructor.name,
227
+ skipSendToRemote: lastArg.skipSendToRemote,
220
228
  };
221
229
  } else {
222
230
  extra = lastArg;
@@ -225,6 +233,11 @@ class IssueReporter {
225
233
  args.splice(1, 1);
226
234
  }
227
235
 
236
+ if (extra.skipSendToRemote) {
237
+ skipSendToRemote = true;
238
+ delete extra.skipSendToRemote;
239
+ }
240
+
228
241
  const date = moment().format('YYYY-MM-DD HH:mm:ss.SSS');
229
242
  const message = args.join(', ');
230
243
  let consoleMessage = message;
@@ -245,7 +258,13 @@ class IssueReporter {
245
258
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
246
259
  oldMethod.apply(oldMethod, [date, consoleMessage]);
247
260
 
248
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
261
+ if (this._callback) {
262
+ this._callback(level, consoleMessage);
263
+ }
264
+
265
+ if (!skipSendToRemote) {
266
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
267
+ }
249
268
  }
250
269
 
251
270
  logRequest(url , options , response , start ) {
@@ -390,7 +409,11 @@ class IssueReporter {
390
409
  },
391
410
  // $FlowFixMe
392
411
  body,
393
- }).catch(() => {
412
+ }).catch((e ) => {
413
+ // $FlowFixMe
414
+ e.skipSendToRemote = true;
415
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
416
+
394
417
  setTimeout(() => {
395
418
  if (isArray) {
396
419
  payload = payload.map(message => {
@@ -437,7 +460,7 @@ var IssueReporter$1 = new IssueReporter();
437
460
 
438
461
  const methods = ['head', 'get', 'post', 'put', 'delete'];
439
462
 
440
- const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
463
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
441
464
 
442
465
  // Use a function here to be able to mock it in tests
443
466
  const realFetch = () => {
@@ -576,7 +599,7 @@ class ApiRequester {
576
599
  };
577
600
 
578
601
  if (this.refreshTokenPromise) {
579
- logger$c.info('A token is already refreshing, waiting ...', { url });
602
+ logger.info('A token is already refreshing, waiting ...', { url });
580
603
  await this.refreshTokenPromise;
581
604
  }
582
605
 
@@ -596,7 +619,7 @@ class ApiRequester {
596
619
  return promise.then(async (err ) => {
597
620
  // Check if the token is still valid
598
621
  if (firstCall && this._checkTokenExpired(response, err)) {
599
- logger$c.warn('token expired', { error: err.reason });
622
+ logger.warn('token expired', { error: err.reason });
600
623
  // Replay the call after refreshing the token
601
624
  return this._replayWithNewToken(err, path, method, body, headers, parse);
602
625
  }
@@ -606,7 +629,7 @@ class ApiRequester {
606
629
  : exceptionClass.fromResponse(err, response.status);
607
630
 
608
631
  if (this.shouldLogErrors) {
609
- logger$c.error('API error', error);
632
+ logger.error('API error', error);
610
633
  }
611
634
 
612
635
  throw error;
@@ -616,7 +639,7 @@ class ApiRequester {
616
639
  return newParse(response, isJson);
617
640
  }).catch(error => {
618
641
  if (this.shouldLogErrors) {
619
- logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
642
+ logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
620
643
  }
621
644
 
622
645
  throw error;
@@ -644,13 +667,13 @@ class ApiRequester {
644
667
  ) {
645
668
  const isTokenNotFound = this._isTokenNotFound(err);
646
669
  let newPath = path;
647
- logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
670
+ logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
648
671
 
649
672
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
650
673
 
651
674
  return this.refreshTokenPromise.then(() => {
652
675
  this.refreshTokenPromise = null;
653
- logger$c.info('token refreshed', { isTokenNotFound });
676
+ logger.info('token refreshed', { isTokenNotFound });
654
677
  if (isTokenNotFound) {
655
678
  const pathParts = path.split('/');
656
679
  pathParts.pop();
@@ -1528,6 +1551,9 @@ class Contact {
1528
1551
  }
1529
1552
 
1530
1553
  static parseMany(response ) {
1554
+ if (!response || !response.results) {
1555
+ return [];
1556
+ }
1531
1557
  return response.results.map(r => Contact.parse(r, response.column_types));
1532
1558
  }
1533
1559
 
@@ -2605,8 +2631,9 @@ class ExternalApp {
2605
2631
 
2606
2632
 
2607
2633
 
2608
-
2634
+
2609
2635
 
2636
+
2610
2637
 
2611
2638
 
2612
2639
  class Meeting {
@@ -2617,9 +2644,10 @@ class Meeting {
2617
2644
 
2618
2645
 
2619
2646
 
2620
-
2647
+
2621
2648
 
2622
2649
 
2650
+
2623
2651
 
2624
2652
  static parse(plain ) {
2625
2653
  return new Meeting({
@@ -2629,24 +2657,43 @@ class Meeting {
2629
2657
  ownerUuids: plain.owner_uuids,
2630
2658
  port: plain.port,
2631
2659
  uuid: plain.uuid,
2632
- number: plain.number,
2660
+ extension: plain.exten,
2633
2661
  persistent: plain.persistent,
2662
+ creationTime: moment(plain.creation_time).toDate(),
2634
2663
  });
2635
2664
  }
2636
2665
 
2666
+ static parseMany(items ) {
2667
+ if (!items) {
2668
+ return [];
2669
+ }
2670
+ return items.map(plain => Meeting.parse(plain));
2671
+ }
2672
+
2637
2673
  static newFrom(meeting ) {
2638
2674
  return newFrom(meeting, Meeting);
2639
2675
  }
2640
2676
 
2641
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2677
+ constructor({
2678
+ uuid,
2679
+ name,
2680
+ guestSipAuthorization,
2681
+ ownerUuids,
2682
+ port,
2683
+ uri,
2684
+ extension,
2685
+ persistent,
2686
+ creationTime,
2687
+ } = {}) {
2642
2688
  this.guestSipAuthorization = guestSipAuthorization;
2643
2689
  this.uri = uri;
2644
2690
  this.name = name;
2645
2691
  this.ownerUuids = ownerUuids;
2646
2692
  this.port = port;
2647
2693
  this.uuid = uuid;
2648
- this.number = number;
2694
+ this.extension = extension;
2649
2695
  this.persistent = persistent;
2696
+ this.creationTime = creationTime;
2650
2697
 
2651
2698
  // Useful to compare instead of instanceof with minified code
2652
2699
  this.type = 'Meeting';
@@ -2724,8 +2771,11 @@ var confdMethods = (client , baseUrl ) => ({
2724
2771
  }
2725
2772
  },
2726
2773
 
2727
- createMyMeeting: (name ) =>
2728
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2774
+ getMyMeetings: () =>
2775
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2776
+
2777
+ createMyMeeting: (name , persistent ) =>
2778
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2729
2779
 
2730
2780
  deleteMyMeeting: (meetingUuid ) =>
2731
2781
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2821,6 +2871,10 @@ class ChatMessage {
2821
2871
 
2822
2872
 
2823
2873
  static parseMany(plain ) {
2874
+ if (!plain || !plain.items) {
2875
+ return [];
2876
+ }
2877
+
2824
2878
  return plain.items.map(item => ChatMessage.parse(item));
2825
2879
  }
2826
2880
 
@@ -2930,6 +2984,9 @@ class Voicemail {
2930
2984
  }
2931
2985
 
2932
2986
  static parseMany(plain ) {
2987
+ if (!plain) {
2988
+ return [];
2989
+ }
2933
2990
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2934
2991
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2935
2992
 
@@ -3039,6 +3096,9 @@ class Call {
3039
3096
 
3040
3097
 
3041
3098
  static parseMany(plain ) {
3099
+ if (!plain) {
3100
+ return [];
3101
+ }
3042
3102
  return plain.map((plainCall ) => Call.parse(plainCall));
3043
3103
  }
3044
3104
 
@@ -3582,6 +3642,9 @@ class Recording {
3582
3642
 
3583
3643
 
3584
3644
  static parseMany(recordings = []) {
3645
+ if (!recordings) {
3646
+ return [];
3647
+ }
3585
3648
  return recordings.map(item => Recording.parse(item));
3586
3649
  }
3587
3650
 
@@ -3683,6 +3746,10 @@ class CallLog {
3683
3746
  }
3684
3747
 
3685
3748
  static parseMany(plain ) {
3749
+ if (!plain || !plain.items) {
3750
+ return [];
3751
+ }
3752
+
3686
3753
  return plain.items.map(item => CallLog.parse(item));
3687
3754
  }
3688
3755
 
@@ -4070,7 +4137,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4070
4137
 
4071
4138
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4072
4139
 
4073
- const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4140
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4074
4141
 
4075
4142
  class CTIPhone extends Emitter {
4076
4143
 
@@ -4083,7 +4150,7 @@ class CTIPhone extends Emitter {
4083
4150
 
4084
4151
  constructor(session , isMobile = false, callbackAllLines = false) {
4085
4152
  super();
4086
- logger$b.info('CTI Phone created');
4153
+ logger$1.info('CTI Phone created');
4087
4154
  this.session = session;
4088
4155
  this.isMobile = isMobile;
4089
4156
  this.callbackAllLines = callbackAllLines;
@@ -4144,7 +4211,7 @@ class CTIPhone extends Emitter {
4144
4211
  }
4145
4212
 
4146
4213
  async makeCall(number , line ) {
4147
- logger$b.info('make CTI call', { number });
4214
+ logger$1.info('make CTI call', { number });
4148
4215
 
4149
4216
  if (!number) {
4150
4217
  return null;
@@ -4167,7 +4234,7 @@ class CTIPhone extends Emitter {
4167
4234
  if (!callSession) {
4168
4235
  return Promise.resolve(null);
4169
4236
  }
4170
- logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4237
+ logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4171
4238
 
4172
4239
  if (!this.currentCall) {
4173
4240
  this.currentCall = callSession.call;
@@ -4180,7 +4247,7 @@ class CTIPhone extends Emitter {
4180
4247
  if (!callSession) {
4181
4248
  return;
4182
4249
  }
4183
- logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4250
+ logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4184
4251
 
4185
4252
  this.currentCall = undefined;
4186
4253
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4190,7 +4257,7 @@ class CTIPhone extends Emitter {
4190
4257
  if (!callSession) {
4191
4258
  return Promise.resolve(false);
4192
4259
  }
4193
- logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4260
+ logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4194
4261
 
4195
4262
  try {
4196
4263
  await CallApi.cancelCall(callSession);
@@ -4201,7 +4268,7 @@ class CTIPhone extends Emitter {
4201
4268
  this.eventEmitter.emit('onCallEnded', callSession);
4202
4269
  return true;
4203
4270
  } catch (e) {
4204
- logger$b.error('hangup CTI call, error', e);
4271
+ logger$1.error('hangup CTI call, error', e);
4205
4272
 
4206
4273
  this.eventEmitter.emit('onCallFailed', callSession);
4207
4274
  return false;
@@ -4214,7 +4281,7 @@ class CTIPhone extends Emitter {
4214
4281
  if (!callSession) {
4215
4282
  return;
4216
4283
  }
4217
- logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4284
+ logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4218
4285
 
4219
4286
  await CallApi.cancelCall(callSession);
4220
4287
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4224,7 +4291,7 @@ class CTIPhone extends Emitter {
4224
4291
  if (!callSession) {
4225
4292
  return;
4226
4293
  }
4227
- logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4294
+ logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4228
4295
 
4229
4296
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4230
4297
  }
@@ -4237,19 +4304,19 @@ class CTIPhone extends Emitter {
4237
4304
  if (!callSession) {
4238
4305
  return;
4239
4306
  }
4240
- logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4307
+ logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4241
4308
 
4242
4309
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4243
4310
  }
4244
4311
 
4245
4312
  async cancelCTIIndirectTransfer(transferId ) {
4246
- logger$b.info('cancel CTI transfer', { transferId });
4313
+ logger$1.info('cancel CTI transfer', { transferId });
4247
4314
 
4248
4315
  return CallApi.cancelCallTransfer(transferId);
4249
4316
  }
4250
4317
 
4251
4318
  async confirmCTIIndirectTransfer(transferId ) {
4252
- logger$b.info('confirm CTI transfer', { transferId });
4319
+ logger$1.info('confirm CTI transfer', { transferId });
4253
4320
 
4254
4321
  return CallApi.confirmCallTransfer(transferId);
4255
4322
  }
@@ -4258,19 +4325,19 @@ class CTIPhone extends Emitter {
4258
4325
  if (!callSession) {
4259
4326
  return;
4260
4327
  }
4261
- logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4328
+ logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4262
4329
 
4263
4330
  return CallApi.sendDTMF(callSession.callId, digits);
4264
4331
  }
4265
4332
 
4266
4333
  onConnectionMade() {
4267
- logger$b.info('on CTI connection made');
4334
+ logger$1.info('on CTI connection made');
4268
4335
 
4269
4336
  this.eventEmitter.emit('onCallAccepted');
4270
4337
  }
4271
4338
 
4272
4339
  async close() {
4273
- logger$b.info('CTI close');
4340
+ logger$1.info('CTI close');
4274
4341
 
4275
4342
  return Promise.resolve();
4276
4343
  }
@@ -4279,7 +4346,7 @@ class CTIPhone extends Emitter {
4279
4346
  if (!callSession) {
4280
4347
  return;
4281
4348
  }
4282
- logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4349
+ logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4283
4350
 
4284
4351
  return CallApi.hold(callSession.callId);
4285
4352
  }
@@ -4288,7 +4355,7 @@ class CTIPhone extends Emitter {
4288
4355
  if (!callSession) {
4289
4356
  return;
4290
4357
  }
4291
- logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4358
+ logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4292
4359
 
4293
4360
  return CallApi.resume(callSession.callId);
4294
4361
  }
@@ -4297,7 +4364,7 @@ class CTIPhone extends Emitter {
4297
4364
  if (!callSession) {
4298
4365
  return;
4299
4366
  }
4300
- logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4367
+ logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4301
4368
 
4302
4369
  return CallApi.mute(callSession.callId);
4303
4370
  }
@@ -4306,7 +4373,7 @@ class CTIPhone extends Emitter {
4306
4373
  if (!callSession) {
4307
4374
  return;
4308
4375
  }
4309
- logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4376
+ logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4310
4377
 
4311
4378
  return CallApi.unmute(callSession.callId);
4312
4379
  }
@@ -4335,6 +4402,10 @@ class CTIPhone extends Emitter {
4335
4402
  return false;
4336
4403
  }
4337
4404
 
4405
+ hasAVideoTrack() {
4406
+ return false;
4407
+ }
4408
+
4338
4409
  getLocalStreamForCall() {
4339
4410
  return null;
4340
4411
  }
@@ -4728,6 +4799,9 @@ class ChatRoom {
4728
4799
 
4729
4800
 
4730
4801
  static parseMany(plain ) {
4802
+ if (!plain || !plain.items) {
4803
+ return [];
4804
+ }
4731
4805
  return plain.items.map(item => ChatRoom.parse(item));
4732
4806
  }
4733
4807
 
@@ -5308,7 +5382,7 @@ const AGENTD_VERSION = '1.0';
5308
5382
  const WEBHOOKD_VERSION = '1.0';
5309
5383
  const AMID_VERSION = '1.0';
5310
5384
 
5311
- const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5385
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5312
5386
 
5313
5387
  class ApiClient {
5314
5388
 
@@ -5360,12 +5434,12 @@ class ApiClient {
5360
5434
  }
5361
5435
 
5362
5436
  async forceRefreshToken() {
5363
- logger$a.info('forcing refresh token, calling callback');
5437
+ logger$2.info('forcing refresh token, calling callback');
5364
5438
  return this.refreshTokenCallback();
5365
5439
  }
5366
5440
 
5367
5441
  async refreshTokenCallback() {
5368
- logger$a.info('refresh token callback called', {
5442
+ logger$2.info('refresh token callback called', {
5369
5443
  refreshToken: this.refreshToken,
5370
5444
  refreshBackend: this.refreshBackend,
5371
5445
  refreshExpiration: this.refreshExpiration,
@@ -5383,7 +5457,7 @@ class ApiClient {
5383
5457
  this.isMobile,
5384
5458
  );
5385
5459
 
5386
- logger$a.info('token refreshed', { token: session.token });
5460
+ logger$2.info('token refreshed', { token: session.token });
5387
5461
 
5388
5462
  if (this.onRefreshToken) {
5389
5463
  this.onRefreshToken(session.token, session);
@@ -5438,7 +5512,7 @@ class ApiClient {
5438
5512
 
5439
5513
  /* */
5440
5514
 
5441
- const parseCandidate$1 = (candidate ) => {
5515
+ const parseCandidate = (candidate ) => {
5442
5516
  if (!candidate) {
5443
5517
  return null;
5444
5518
  }
@@ -5451,10 +5525,6 @@ const getSrflxOrRelay = (candidates ) =>
5451
5525
  candidates
5452
5526
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5453
5527
 
5454
- const areCandidateValid = (candidates ) =>
5455
- getSrflxOrRelay(candidates)
5456
- .length > 0;
5457
-
5458
5528
  const getVideoDirection = (sdp ) => {
5459
5529
  const parsedSdp = sdpParser.parse(sdp);
5460
5530
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5507,8 +5577,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5507
5577
  /* global RTCSessionDescriptionInit, navigator */
5508
5578
 
5509
5579
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5510
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5511
- const WAIT_FOR_ICE_TIMEOUT = 500;
5512
5580
 
5513
5581
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5514
5582
  const wazoMediaStreamFactory = (constraints ) => {
@@ -5598,7 +5666,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5598
5666
  this.peerConnectionDelegate.onicecandidate = event => {
5599
5667
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5600
5668
  if (event.candidate) {
5601
- this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5669
+ this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5602
5670
  }
5603
5671
  };
5604
5672
 
@@ -5698,38 +5766,6 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5698
5766
  this._peerConnection = undefined;
5699
5767
  }
5700
5768
 
5701
- async _waitForValidGatheredIce() {
5702
- let tries = 0;
5703
-
5704
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
5705
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
5706
- tries,
5707
- max: MAX_WAIT_FOR_ICE_TRIES,
5708
- });
5709
-
5710
- tries++;
5711
-
5712
- // eslint-disable-next-line no-await-in-loop
5713
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
5714
- }
5715
-
5716
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
5717
- const errorMsg = 'No valid candidates found, can\'t answer the call';
5718
- const error = new Error(errorMsg);
5719
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
5720
-
5721
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
5722
- this.eventEmitter.emit('error', error);
5723
-
5724
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5725
- }
5726
-
5727
- // eslint-disable-next-line
5728
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5729
-
5730
- return this.getLocalSessionDescription();
5731
- }
5732
-
5733
5769
  // Overridden to send `inactive` in conference
5734
5770
  updateDirection(options , isConference = false,
5735
5771
  audioOnly = false) {
@@ -6094,7 +6130,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6094
6130
  const SEND_STATS_DELAY = 5000;
6095
6131
 
6096
6132
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6097
- const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6133
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6098
6134
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6099
6135
 
6100
6136
  // events
@@ -6108,14 +6144,14 @@ const TRANSPORT_ERROR = 'transportError';
6108
6144
  const MESSAGE = 'message';
6109
6145
  const ACCEPTED = 'accepted';
6110
6146
  const REJECTED = 'rejected';
6111
- const ON_TRACK$1 = 'onTrack';
6112
- const ON_REINVITE$1 = 'reinvite';
6147
+ const ON_TRACK = 'onTrack';
6148
+ const ON_REINVITE = 'reinvite';
6113
6149
  const ON_ERROR = 'onError';
6114
6150
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6115
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
6116
- const ON_DISCONNECTED$1 = 'onDisconnected';
6151
+ const ON_NETWORK_STATS = 'onNetworkStats';
6152
+ const ON_DISCONNECTED = 'onDisconnected';
6117
6153
 
6118
- const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6154
+ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6119
6155
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6120
6156
  class CanceledCallError extends Error {}
6121
6157
 
@@ -6251,12 +6287,12 @@ class WebRTCClient extends Emitter {
6251
6287
  this.MESSAGE = MESSAGE;
6252
6288
  this.ACCEPTED = ACCEPTED;
6253
6289
  this.REJECTED = REJECTED;
6254
- this.ON_TRACK = ON_TRACK$1;
6255
- this.ON_REINVITE = ON_REINVITE$1;
6290
+ this.ON_TRACK = ON_TRACK;
6291
+ this.ON_REINVITE = ON_REINVITE;
6256
6292
  this.ON_ERROR = ON_ERROR;
6257
6293
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6258
- this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6259
- this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6294
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6295
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
6260
6296
  }
6261
6297
 
6262
6298
  configureMedia(media ) {
@@ -6273,13 +6309,13 @@ class WebRTCClient extends Emitter {
6273
6309
 
6274
6310
  createUserAgent(configOverrides ) {
6275
6311
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6276
- logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6312
+ logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6277
6313
 
6278
6314
  webRTCConfiguration.delegate = {
6279
6315
  onConnect: this.onConnect.bind(this),
6280
6316
  onDisconnect: this.onDisconnect.bind(this),
6281
6317
  onInvite: (invitation ) => {
6282
- logger$9.info('sdk webrtc on invite', {
6318
+ logger$3.info('sdk webrtc on invite', {
6283
6319
  method: 'delegate.onInvite',
6284
6320
  id: invitation.id,
6285
6321
  remoteURI: invitation.remoteURI,
@@ -6322,7 +6358,7 @@ class WebRTCClient extends Emitter {
6322
6358
  }
6323
6359
 
6324
6360
  onConnect() {
6325
- logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6361
+ logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6326
6362
  this.eventEmitter.emit(CONNECTED);
6327
6363
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6328
6364
  this.registerer.waitingToggle(false);
@@ -6331,7 +6367,7 @@ class WebRTCClient extends Emitter {
6331
6367
  }
6332
6368
 
6333
6369
  async onDisconnect(error ) {
6334
- logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6370
+ logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6335
6371
  this.connectionPromise = null;
6336
6372
  // The UA will attempt to reconnect automatically when an error occurred
6337
6373
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6356,37 +6392,37 @@ class WebRTCClient extends Emitter {
6356
6392
  };
6357
6393
 
6358
6394
  if (this.skipRegister) {
6359
- logger$9.info('sdk webrtc skip register...', logInfo);
6395
+ logger$3.info('sdk webrtc skip register...', logInfo);
6360
6396
  return Promise.resolve();
6361
6397
  }
6362
6398
 
6363
- logger$9.info('sdk webrtc registering...', logInfo);
6399
+ logger$3.info('sdk webrtc registering...', logInfo);
6364
6400
 
6365
6401
  if (!this.userAgent) {
6366
- logger$9.info('sdk webrtc recreating User Agent');
6402
+ logger$3.info('sdk webrtc recreating User Agent');
6367
6403
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6368
6404
  }
6369
6405
  if (!this.userAgent || this.isRegistered()) {
6370
- logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6406
+ logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6371
6407
  return Promise.resolve();
6372
6408
  }
6373
6409
 
6374
6410
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6375
- logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6411
+ logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6376
6412
  return Promise.resolve();
6377
6413
  }
6378
6414
 
6379
6415
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6380
6416
 
6381
6417
  const onRegisterFailed = () => {
6382
- logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6418
+ logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6383
6419
  this.connectionPromise = null;
6384
6420
  if (this.registerer && this.registerer.waiting) {
6385
6421
  this.registerer.waitingToggle(false);
6386
6422
  }
6387
6423
 
6388
6424
  if (tries <= MAX_REGISTER_TRIES) {
6389
- logger$9.info('sdk webrtc registering, retrying...', { tries });
6425
+ logger$3.info('sdk webrtc registering, retrying...', { tries });
6390
6426
  setTimeout(() => this.register(tries + 1), 300);
6391
6427
  }
6392
6428
  };
@@ -6395,18 +6431,18 @@ class WebRTCClient extends Emitter {
6395
6431
  // Avoid race condition with the close method called just before register and setting userAgent to null
6396
6432
  // during the resolution of the primise.
6397
6433
  if (!this.userAgent) {
6398
- logger$9.info('sdk webrtc recreating User Agent after connection');
6434
+ logger$3.info('sdk webrtc recreating User Agent after connection');
6399
6435
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6400
6436
  }
6401
6437
 
6402
- logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6438
+ logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6403
6439
  this.registerer = new Registerer(this.userAgent, registerOptions);
6404
6440
  this.connectionPromise = null;
6405
6441
  this._monkeyPatchRegisterer(this.registerer);
6406
6442
 
6407
6443
  // Bind registerer events
6408
6444
  this.registerer.stateChange.addListener(newState => {
6409
- logger$9.info('sdk webrtc registering, state changed', { newState });
6445
+ logger$3.info('sdk webrtc registering, state changed', { newState });
6410
6446
 
6411
6447
  if (newState === RegistererState.Registered && this.registerer
6412
6448
  && this.registerer.state === RegistererState.Registered) {
@@ -6419,7 +6455,7 @@ class WebRTCClient extends Emitter {
6419
6455
  const options = {
6420
6456
  requestDelegate: {
6421
6457
  onReject: response => {
6422
- logger$9.error('sdk webrtc registering, rejected', { response });
6458
+ logger$3.error('sdk webrtc registering, rejected', { response });
6423
6459
 
6424
6460
  onRegisterFailed();
6425
6461
  },
@@ -6427,13 +6463,13 @@ class WebRTCClient extends Emitter {
6427
6463
  };
6428
6464
 
6429
6465
  return this.registerer.register(options).catch((e) => {
6430
- logger$9.error('sdk webrtc registering, error', e);
6466
+ logger$3.error('sdk webrtc registering, error', e);
6431
6467
 
6432
6468
  this.eventEmitter.emit(REGISTRATION_FAILED);
6433
6469
  return e;
6434
6470
  });
6435
6471
  }).catch(error => {
6436
- logger$9.error('sdk webrtc registering, transport error', error);
6472
+ logger$3.error('sdk webrtc registering, transport error', error);
6437
6473
  onRegisterFailed();
6438
6474
  });
6439
6475
  }
@@ -6462,21 +6498,21 @@ class WebRTCClient extends Emitter {
6462
6498
  }
6463
6499
 
6464
6500
  unregister() {
6465
- logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6501
+ logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6466
6502
  if (!this.registerer) {
6467
6503
  return Promise.resolve();
6468
6504
  }
6469
6505
 
6470
6506
  try {
6471
6507
  return this.registerer.unregister().then(() => {
6472
- logger$9.info('sdk webrtc unregistered');
6508
+ logger$3.info('sdk webrtc unregistered');
6473
6509
  this._cleanupRegister();
6474
6510
  }).catch(e => {
6475
- logger$9.error('sdk webrtc unregistering, promise error', e);
6511
+ logger$3.error('sdk webrtc unregistering, promise error', e);
6476
6512
  this._cleanupRegister();
6477
6513
  });
6478
6514
  } catch (e) {
6479
- logger$9.error('sdk webrtc unregistering, error', e);
6515
+ logger$3.error('sdk webrtc unregistering, error', e);
6480
6516
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6481
6517
  // error when the registerer is in a bad state
6482
6518
  this._cleanupRegister();
@@ -6484,7 +6520,7 @@ class WebRTCClient extends Emitter {
6484
6520
  }
6485
6521
 
6486
6522
  stop() {
6487
- logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6523
+ logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6488
6524
  if (!this.userAgent) {
6489
6525
  return Promise.resolve();
6490
6526
  }
@@ -6492,12 +6528,12 @@ class WebRTCClient extends Emitter {
6492
6528
  return this.userAgent.stop().then(() => {
6493
6529
  return this._cleanupRegister();
6494
6530
  }).catch(e => {
6495
- logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6531
+ logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6496
6532
  });
6497
6533
  }
6498
6534
 
6499
6535
  call(number , enableVideo , audioOnly = false, conference = false) {
6500
- logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6536
+ logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6501
6537
  const inviterOptions = {
6502
6538
  sessionDescriptionHandlerOptionsReInvite: {
6503
6539
  conference,
@@ -6522,11 +6558,13 @@ class WebRTCClient extends Emitter {
6522
6558
  const inviteOptions = {
6523
6559
  requestDelegate: {
6524
6560
  onAccept: (response ) => {
6525
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6561
+ if (session.sessionDescriptionHandler.peerConnection) {
6562
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6563
+ }
6526
6564
  this._onAccepted(session, response.session, true);
6527
6565
  },
6528
6566
  onReject: (response ) => {
6529
- logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6567
+ logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6530
6568
  this._stopSendingStats(session);
6531
6569
  this.stopNetworkMonitoring(session);
6532
6570
 
@@ -6549,11 +6587,11 @@ class WebRTCClient extends Emitter {
6549
6587
  }
6550
6588
 
6551
6589
  answer(session , enableVideo ) {
6552
- logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6590
+ logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6553
6591
 
6554
6592
  if (!session || !session.accept) {
6555
6593
  const error = 'No session to answer, or not an invitation';
6556
- logger$9.warn(error);
6594
+ logger$3.warn(error);
6557
6595
  return Promise.reject(new Error(error));
6558
6596
  }
6559
6597
  const options = {
@@ -6563,15 +6601,15 @@ class WebRTCClient extends Emitter {
6563
6601
  return session.accept(options).then(() => {
6564
6602
  if (session.isCanceled) {
6565
6603
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6566
- logger$9.error(message, { id: session.id });
6604
+ logger$3.error(message, { id: session.id });
6567
6605
  this.onCallEnded(session);
6568
6606
 
6569
6607
  throw new CanceledCallError(message);
6570
6608
  }
6571
- logger$9.info('sdk webrtc answer, accepted.');
6609
+ logger$3.info('sdk webrtc answer, accepted.');
6572
6610
  this._onAccepted(session);
6573
6611
  }).catch(e => {
6574
- logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6612
+ logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6575
6613
 
6576
6614
  throw e;
6577
6615
  });
@@ -6579,7 +6617,7 @@ class WebRTCClient extends Emitter {
6579
6617
 
6580
6618
  hangup(session ) {
6581
6619
  const { state, id } = session;
6582
- logger$9.info('sdk webrtc hangup call', { id, state });
6620
+ logger$3.info('sdk webrtc hangup call', { id, state });
6583
6621
 
6584
6622
  try {
6585
6623
  this._stopSendingStats(session);
@@ -6608,7 +6646,7 @@ class WebRTCClient extends Emitter {
6608
6646
 
6609
6647
  return bye();
6610
6648
  } catch (error) {
6611
- logger$9.warn('sdk webrtc hangup, error', error);
6649
+ logger$3.warn('sdk webrtc hangup, error', error);
6612
6650
  }
6613
6651
 
6614
6652
  return null;
@@ -6626,7 +6664,7 @@ class WebRTCClient extends Emitter {
6626
6664
  // Fetch and emit an event at `interval` with session network stats
6627
6665
  startNetworkMonitoring(session , interval = 1000) {
6628
6666
  const sessionId = this.getSipSessionId(session);
6629
- logger$9.info('starting network inspection', { id: sessionId });
6667
+ logger$3.info('starting network inspection', { id: sessionId });
6630
6668
 
6631
6669
  this.sessionNetworkStats[sessionId] = [];
6632
6670
 
@@ -6636,7 +6674,7 @@ class WebRTCClient extends Emitter {
6636
6674
  stopNetworkMonitoring(session ) {
6637
6675
  const sessionId = this.getSipSessionId(session);
6638
6676
  const exists = sessionId in this.networkMonitoringInterval;
6639
- logger$9.info('stopping network inspection', { id: sessionId, exists });
6677
+ logger$3.info('stopping network inspection', { id: sessionId, exists });
6640
6678
 
6641
6679
  if (exists) {
6642
6680
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6646,17 +6684,17 @@ class WebRTCClient extends Emitter {
6646
6684
  }
6647
6685
 
6648
6686
  reject(session ) {
6649
- logger$9.info('sdk webrtc reject call', { id: session.id });
6687
+ logger$3.info('sdk webrtc reject call', { id: session.id });
6650
6688
 
6651
6689
  try {
6652
6690
  return session.reject ? session.reject() : session.cancel();
6653
6691
  } catch (e) {
6654
- logger$9.warn('Error when rejecting call', e.message, e.stack);
6692
+ logger$3.warn('Error when rejecting call', e.message, e.stack);
6655
6693
  }
6656
6694
  }
6657
6695
 
6658
6696
  async close() {
6659
- logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6697
+ logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6660
6698
  this._cleanupMedia();
6661
6699
  this.connectionPromise = null;
6662
6700
 
@@ -6687,7 +6725,7 @@ class WebRTCClient extends Emitter {
6687
6725
  // eg: "INVITE not rejectable in state Completed"
6688
6726
  }
6689
6727
  this.userAgent = null;
6690
- logger$9.info('sdk webrtc client closed');
6728
+ logger$3.info('sdk webrtc client closed');
6691
6729
  }
6692
6730
 
6693
6731
  getNumber(session ) {
@@ -6700,13 +6738,13 @@ class WebRTCClient extends Emitter {
6700
6738
  }
6701
6739
 
6702
6740
  mute(session ) {
6703
- logger$9.info('sdk webrtc mute', { id: session.id });
6741
+ logger$3.info('sdk webrtc mute', { id: session.id });
6704
6742
 
6705
6743
  this._toggleAudio(session, true);
6706
6744
  }
6707
6745
 
6708
6746
  unmute(session ) {
6709
- logger$9.info('sdk webrtc unmute', { id: session.id });
6747
+ logger$3.info('sdk webrtc unmute', { id: session.id });
6710
6748
 
6711
6749
  this._toggleAudio(session, false);
6712
6750
  }
@@ -6746,13 +6784,13 @@ class WebRTCClient extends Emitter {
6746
6784
  }
6747
6785
 
6748
6786
  toggleCameraOn(session ) {
6749
- logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6787
+ logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6750
6788
 
6751
6789
  this._toggleVideo(session, false);
6752
6790
  }
6753
6791
 
6754
6792
  toggleCameraOff(session ) {
6755
- logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6793
+ logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6756
6794
 
6757
6795
  this._toggleVideo(session, true);
6758
6796
  }
@@ -6761,7 +6799,7 @@ class WebRTCClient extends Emitter {
6761
6799
  const sessionId = this.getSipSessionId(session);
6762
6800
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6763
6801
 
6764
- logger$9.info('sdk webrtc hold', {
6802
+ logger$3.info('sdk webrtc hold', {
6765
6803
  sessionId,
6766
6804
  keys: Object.keys(this.heldSessions),
6767
6805
  pendingReinvite: !!session.pendingReinvite,
@@ -6810,7 +6848,7 @@ class WebRTCClient extends Emitter {
6810
6848
  const sessionId = this.getSipSessionId(session);
6811
6849
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
6812
6850
 
6813
- logger$9.info('sdk webrtc unhold', {
6851
+ logger$3.info('sdk webrtc unhold', {
6814
6852
  sessionId,
6815
6853
  keys: Object.keys(this.heldSessions),
6816
6854
  pendingReinvite: !!session.pendingReinvite,
@@ -6958,7 +6996,7 @@ class WebRTCClient extends Emitter {
6958
6996
  if (!session.sessionDescriptionHandler) {
6959
6997
  return;
6960
6998
  }
6961
- logger$9.info('Sending DTMF', {
6999
+ logger$3.info('Sending DTMF', {
6962
7000
  id: this.getSipSessionId(session),
6963
7001
  tone,
6964
7002
  });
@@ -6974,7 +7012,7 @@ class WebRTCClient extends Emitter {
6974
7012
  transfer(session , target ) {
6975
7013
  this.hold(session);
6976
7014
 
6977
- logger$9.info('Transfering a session', {
7015
+ logger$3.info('Transfering a session', {
6978
7016
  id: this.getSipSessionId(session),
6979
7017
  target,
6980
7018
  });
@@ -6996,17 +7034,17 @@ class WebRTCClient extends Emitter {
6996
7034
  atxfer(session ) {
6997
7035
  this.hold(session);
6998
7036
 
6999
- logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7037
+ logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7000
7038
 
7001
7039
  const result = {
7002
7040
  newSession: null,
7003
7041
  init: async (target ) => {
7004
- logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7042
+ logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7005
7043
 
7006
7044
  result.newSession = await this.call(target);
7007
7045
  },
7008
7046
  complete: () => {
7009
- logger$9.info('webrtc transfer completed', {
7047
+ logger$3.info('webrtc transfer completed', {
7010
7048
  id: this.getSipSessionId(session),
7011
7049
  referId: this.getSipSessionId(result.newSession),
7012
7050
  });
@@ -7027,7 +7065,7 @@ class WebRTCClient extends Emitter {
7027
7065
  return;
7028
7066
  }
7029
7067
 
7030
- logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7068
+ logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7031
7069
 
7032
7070
  try {
7033
7071
  sipSession.message({
@@ -7069,7 +7107,7 @@ class WebRTCClient extends Emitter {
7069
7107
  }
7070
7108
 
7071
7109
  changeAudioOutputVolume(volume ) {
7072
- logger$9.info('Changing audio output volume', { volume });
7110
+ logger$3.info('Changing audio output volume', { volume });
7073
7111
 
7074
7112
  Object.values(this.audioElements).forEach(audioElement => {
7075
7113
  if (audioElement instanceof HTMLAudioElement) {
@@ -7081,7 +7119,7 @@ class WebRTCClient extends Emitter {
7081
7119
  }
7082
7120
 
7083
7121
  changeAudioOutputDevice(id ) {
7084
- logger$9.info('Changing audio output device', { id });
7122
+ logger$3.info('Changing audio output device', { id });
7085
7123
 
7086
7124
  Object.values(this.audioElements).forEach(audioElement => {
7087
7125
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7098,7 +7136,7 @@ class WebRTCClient extends Emitter {
7098
7136
 
7099
7137
  changeAudioInputDevice(id , session ) {
7100
7138
  const currentId = this.getAudioDeviceId();
7101
- logger$9.info('setting audio input device', { id, currentId, session: !!session });
7139
+ logger$3.info('setting audio input device', { id, currentId, session: !!session });
7102
7140
 
7103
7141
  if (id === currentId) {
7104
7142
  return null;
@@ -7144,7 +7182,7 @@ class WebRTCClient extends Emitter {
7144
7182
 
7145
7183
  setVideoInputDevice(id ) {
7146
7184
  const currentId = this.getVideoDeviceId();
7147
- logger$9.info('setting video input device', { id, currentId });
7185
+ logger$3.info('setting video input device', { id, currentId });
7148
7186
 
7149
7187
  if (id === currentId) {
7150
7188
  return null;
@@ -7169,7 +7207,7 @@ class WebRTCClient extends Emitter {
7169
7207
  const sessionId = this.getSipSessionId(session);
7170
7208
  const localStream = this.getLocalStream(sessionId);
7171
7209
 
7172
- logger$9.info('changing video input device', { id, sessionId });
7210
+ logger$3.info('changing video input device', { id, sessionId });
7173
7211
 
7174
7212
  // Release old video stream
7175
7213
  if (localStream) {
@@ -7237,7 +7275,7 @@ class WebRTCClient extends Emitter {
7237
7275
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7238
7276
  const desktop = newConstraints && newConstraints.desktop;
7239
7277
 
7240
- logger$9.info('Sending reinvite', {
7278
+ logger$3.info('Sending reinvite', {
7241
7279
  id: this.getSipSessionId(sipSession),
7242
7280
  newConstraints,
7243
7281
  conference,
@@ -7275,7 +7313,7 @@ class WebRTCClient extends Emitter {
7275
7313
  sipSession.incomingInviteRequest.message.body = response.message.body;
7276
7314
  }
7277
7315
 
7278
- logger$9.info('on re-INVITE accepted', {
7316
+ logger$3.info('on re-INVITE accepted', {
7279
7317
  id: this.getSipSessionId(sipSession),
7280
7318
  wasMuted,
7281
7319
  shouldDoScreenSharing,
@@ -7293,7 +7331,7 @@ class WebRTCClient extends Emitter {
7293
7331
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7294
7332
  }
7295
7333
 
7296
- return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7334
+ return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7297
7335
  },
7298
7336
  },
7299
7337
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7394,6 +7432,16 @@ class WebRTCClient extends Emitter {
7394
7432
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7395
7433
  }
7396
7434
 
7435
+ // Useful in a react-native environment when remoteMediaStream is not updated
7436
+ getRemoteVideoStreamFromPc(sessionId ) {
7437
+ const pc = this.getPeerConnection(sessionId);
7438
+ if (!pc) {
7439
+ return null;
7440
+ }
7441
+
7442
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7443
+ }
7444
+
7397
7445
  hasVideo(sessionId ) {
7398
7446
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7399
7447
  }
@@ -7440,7 +7488,7 @@ class WebRTCClient extends Emitter {
7440
7488
  }
7441
7489
 
7442
7490
  startHeartbeat() {
7443
- logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7491
+ logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7444
7492
  if (!this.userAgent) {
7445
7493
  this.heartbeat.stop();
7446
7494
  return;
@@ -7453,7 +7501,7 @@ class WebRTCClient extends Emitter {
7453
7501
  }
7454
7502
 
7455
7503
  stopHeartbeat() {
7456
- logger$9.info('sdk webrtc stop heartbeat');
7504
+ logger$3.info('sdk webrtc stop heartbeat');
7457
7505
  this.heartbeat.stop();
7458
7506
  }
7459
7507
 
@@ -7474,7 +7522,7 @@ class WebRTCClient extends Emitter {
7474
7522
  }
7475
7523
 
7476
7524
  attemptReconnection() {
7477
- logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7525
+ logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7478
7526
  if (!this.userAgent) {
7479
7527
  return;
7480
7528
  }
@@ -7499,7 +7547,7 @@ class WebRTCClient extends Emitter {
7499
7547
  return;
7500
7548
  }
7501
7549
 
7502
- logger$9.info('setting local media stream', {
7550
+ logger$3.info('setting local media stream', {
7503
7551
  sipSessionId,
7504
7552
  tracks: newStream ? newStream.getTracks() : null,
7505
7553
  });
@@ -7516,7 +7564,7 @@ class WebRTCClient extends Emitter {
7516
7564
 
7517
7565
  const oldStream = this.getLocalStream(sipSessionId);
7518
7566
 
7519
- logger$9.info('updating local stream', {
7567
+ logger$3.info('updating local stream', {
7520
7568
  sipSessionId,
7521
7569
  oldStream: !!oldStream,
7522
7570
  tracks: newStream.getTracks(),
@@ -7536,7 +7584,7 @@ class WebRTCClient extends Emitter {
7536
7584
  const remoteStream = this.getRemoteStream(sessionId);
7537
7585
  const pc = this.getPeerConnection(sessionId);
7538
7586
 
7539
- logger$9.info('Updating remote stream', {
7587
+ logger$3.info('Updating remote stream', {
7540
7588
  sessionId,
7541
7589
  tracks: remoteStream ? remoteStream.getTracks() : null,
7542
7590
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7562,7 +7610,7 @@ class WebRTCClient extends Emitter {
7562
7610
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7563
7611
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7564
7612
 
7565
- logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7613
+ logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7566
7614
 
7567
7615
  return {
7568
7616
  constraints: {
@@ -7611,7 +7659,7 @@ class WebRTCClient extends Emitter {
7611
7659
  }
7612
7660
 
7613
7661
  _onTransportError() {
7614
- logger$9.error('on transport error');
7662
+ logger$3.error('on transport error');
7615
7663
  this.eventEmitter.emit(TRANSPORT_ERROR);
7616
7664
  this.attemptReconnection();
7617
7665
  }
@@ -7620,7 +7668,7 @@ class WebRTCClient extends Emitter {
7620
7668
  const body = message && typeof message === 'object' ? message.data : message;
7621
7669
  if (body && body.indexOf('200 OK') !== -1) {
7622
7670
  if (this.hasHeartbeat()) {
7623
- logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7671
+ logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7624
7672
 
7625
7673
  this.heartbeat.onHeartbeat();
7626
7674
  if (this.heartbeatCb) {
@@ -7631,7 +7679,7 @@ class WebRTCClient extends Emitter {
7631
7679
  }
7632
7680
 
7633
7681
  async _onHeartbeatTimeout() {
7634
- logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7682
+ logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7635
7683
 
7636
7684
  if (this.heartbeatTimeoutCb) {
7637
7685
  this.heartbeatTimeoutCb();
@@ -7643,7 +7691,7 @@ class WebRTCClient extends Emitter {
7643
7691
  try {
7644
7692
  await this.userAgent.transport.disconnect();
7645
7693
  } catch (e) {
7646
- logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7694
+ logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7647
7695
  }
7648
7696
  }
7649
7697
 
@@ -7676,31 +7724,31 @@ class WebRTCClient extends Emitter {
7676
7724
  }
7677
7725
 
7678
7726
  _connectIfNeeded() {
7679
- logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7727
+ logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7680
7728
  if (!this.userAgent) {
7681
- logger$9.info('need to recreate User Agent');
7729
+ logger$3.info('need to recreate User Agent');
7682
7730
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7683
7731
  }
7684
7732
 
7685
7733
  if (this.isConnected()) {
7686
- logger$9.info('webrtc sdk, already connected');
7734
+ logger$3.info('webrtc sdk, already connected');
7687
7735
  return Promise.resolve();
7688
7736
  }
7689
7737
 
7690
7738
  if (this.isConnecting()) {
7691
- logger$9.info('webrtc sdk, already connecting...');
7739
+ logger$3.info('webrtc sdk, already connecting...');
7692
7740
 
7693
7741
  this.connectionPromise = this.userAgent.transport.connectPromise;
7694
7742
  return this.connectionPromise;
7695
7743
  }
7696
7744
 
7697
7745
  if (this.connectionPromise) {
7698
- logger$9.info('webrtc sdk, connection promise connecting...');
7746
+ logger$3.info('webrtc sdk, connection promise connecting...');
7699
7747
  // $FlowFixMe
7700
7748
  return this.connectionPromise;
7701
7749
  }
7702
7750
 
7703
- logger$9.info('WebRTC UA needs to connect');
7751
+ logger$3.info('WebRTC UA needs to connect');
7704
7752
 
7705
7753
  // Force UA to reconnect
7706
7754
  if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
@@ -7825,7 +7873,7 @@ class WebRTCClient extends Emitter {
7825
7873
 
7826
7874
  sdh.peerConnectionDelegate = {
7827
7875
  onicecandidateerror: (error ) => {
7828
- logger$9.error('on icecandidate error', {
7876
+ logger$3.error('on icecandidate error', {
7829
7877
  address: error.address,
7830
7878
  port: error.port,
7831
7879
  errorCode: error.errorCode,
@@ -7854,7 +7902,7 @@ class WebRTCClient extends Emitter {
7854
7902
  updatedNumber = session.assertedIdentity.uri.normal.user;
7855
7903
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
7856
7904
  }
7857
- logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7905
+ logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7858
7906
 
7859
7907
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
7860
7908
 
@@ -7870,12 +7918,12 @@ class WebRTCClient extends Emitter {
7870
7918
 
7871
7919
  this._setupMedias(session);
7872
7920
 
7873
- return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7921
+ return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7874
7922
  };
7875
7923
  }
7876
7924
 
7877
7925
  _onAccepted(session , sessionDialog , withEvent = true) {
7878
- logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7926
+ logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7879
7927
 
7880
7928
  this.storeSipSession(session);
7881
7929
 
@@ -7887,14 +7935,14 @@ class WebRTCClient extends Emitter {
7887
7935
  const onTrack = (event ) => {
7888
7936
  const isAudioOnly = this._isAudioOnly(session);
7889
7937
  const { kind, label, readyState, id, muted } = event.track;
7890
- logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7938
+ logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7891
7939
 
7892
7940
  // Stop video track in audio only mode
7893
7941
  if (isAudioOnly && kind === 'video') {
7894
7942
  event.track.stop();
7895
7943
  }
7896
7944
 
7897
- this.eventEmitter.emit(ON_TRACK$1, session, event);
7945
+ this.eventEmitter.emit(ON_TRACK, session, event);
7898
7946
  };
7899
7947
 
7900
7948
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -7904,8 +7952,9 @@ class WebRTCClient extends Emitter {
7904
7952
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7905
7953
 
7906
7954
  pc.oniceconnectionstatechange = () => {
7955
+ logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
7907
7956
  if (pc.iceConnectionState === 'disconnected') {
7908
- this.eventEmitter.emit(ON_DISCONNECTED$1);
7957
+ this.eventEmitter.emit(ON_DISCONNECTED);
7909
7958
  }
7910
7959
  };
7911
7960
 
@@ -8076,10 +8125,10 @@ class WebRTCClient extends Emitter {
8076
8125
 
8077
8126
  _stopSendingStats(session ) {
8078
8127
  const sessionId = this.getSipSessionId(session);
8079
- logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8128
+ logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8080
8129
 
8081
8130
  if (sessionId in this.statsIntervals) {
8082
- logger$9.trace('Stop sending stats for call', { sessionId });
8131
+ logger$3.trace('Stop sending stats for call', { sessionId });
8083
8132
  this.statsIntervals[sessionId]();
8084
8133
  delete this.statsIntervals[sessionId];
8085
8134
  }
@@ -8095,7 +8144,7 @@ class WebRTCClient extends Emitter {
8095
8144
  try {
8096
8145
  await this.userAgent.transport.disconnect();
8097
8146
  } catch (e) {
8098
- logger$9.error('WebRTC transport disconnect, error', e);
8147
+ logger$3.error('WebRTC transport disconnect, error', e);
8099
8148
  }
8100
8149
  }
8101
8150
  }
@@ -8132,25 +8181,25 @@ class WebRTCClient extends Emitter {
8132
8181
 
8133
8182
  stats.forEach(report => {
8134
8183
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8135
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8184
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8136
8185
  }
8137
8186
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8138
- audioBytesSent += report.bytesSent;
8187
+ audioBytesSent += Number(report.bytesSent);
8139
8188
  }
8140
8189
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8141
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8190
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8142
8191
  }
8143
8192
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8144
- packetsLost += report.packetsLost;
8145
- networkStats.packetsReceived = report.packetsReceived;
8146
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8193
+ packetsLost += Number(report.packetsLost);
8194
+ networkStats.packetsReceived = Number(report.packetsReceived);
8195
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8147
8196
  }
8148
8197
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8149
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8198
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8150
8199
  }
8151
8200
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8152
8201
  if ('framesPerSecond' in report) {
8153
- networkStats.framesPerSecond = report.framesPerSecond;
8202
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8154
8203
  }
8155
8204
  if ('framerateMean' in report) {
8156
8205
  // framerateMean is only available in FF
@@ -8158,34 +8207,38 @@ class WebRTCClient extends Emitter {
8158
8207
  }
8159
8208
  }
8160
8209
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8161
- packetsLost += report.packetsLost;
8162
- networkStats.roundTripTime = report.roundTripTime;
8163
- networkStats.jitter = report.jitter;
8210
+ packetsLost += Number(report.packetsLost);
8211
+ networkStats.roundTripTime = Number(report.roundTripTime);
8212
+ networkStats.jitter = Number(report.jitter);
8164
8213
  }
8165
8214
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8166
- packetsLost += report.packetsLost;
8215
+ packetsLost += Number(report.packetsLost);
8167
8216
  }
8168
8217
  if (report.type === 'transport') {
8169
- transportSent += report.bytesSent;
8170
- transportReceived += report.bytesReceived;
8218
+ transportSent += Number(report.bytesSent);
8219
+ transportReceived += Number(report.bytesReceived);
8171
8220
  }
8172
8221
  });
8173
8222
 
8174
8223
  networkStats.packetsLost = packetsLost;
8175
- networkStats.audioBytesSent = audioBytesSent;
8224
+ networkStats.totalAudioBytesSent = audioBytesSent;
8225
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8226
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8176
8227
  networkStats.audioBytesReceived = audioBytesReceived;
8177
- networkStats.videoBytesSent = videoBytesSent;
8178
- networkStats.videoBytesReceived = videoBytesReceived;
8228
+ networkStats.totalVideoBytesSent = videoBytesSent;
8229
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8230
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8231
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8232
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8179
8233
  networkStats.transportSent = transportSent;
8180
- networkStats.transportReceived = transportReceived;
8234
+ networkStats.totalTransportReceived = transportReceived;
8235
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8181
8236
 
8182
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8183
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8184
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8237
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8238
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8239
+ + networkStats.transportSent;
8185
8240
 
8186
- networkStats.bandwidth = bandwidth;
8187
-
8188
- this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8241
+ this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8189
8242
  this.sessionNetworkStats[sessionId].push(networkStats);
8190
8243
  }
8191
8244
 
@@ -8193,7 +8246,7 @@ class WebRTCClient extends Emitter {
8193
8246
 
8194
8247
  //
8195
8248
 
8196
- const SOCKET_EVENTS$1 = {
8249
+ const SOCKET_EVENTS = {
8197
8250
  ON_OPEN: 'onopen',
8198
8251
  ON_MESSAGE: 'onmessage',
8199
8252
  ON_ERROR: 'onerror',
@@ -8279,6 +8332,7 @@ const AGENT_PAUSED = 'agent_paused';
8279
8332
  const AGENT_UNPAUSED = 'agent_unpaused';
8280
8333
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
8281
8334
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
8335
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
8282
8336
 
8283
8337
  const BLACKLIST_EVENTS = [
8284
8338
  CHAT_MESSAGE_SENT,
@@ -8288,7 +8342,7 @@ const BLACKLIST_EVENTS = [
8288
8342
  ];
8289
8343
 
8290
8344
  const HEARTBEAT_ENGINE_VERSION = '20.09';
8291
- const logger$8 = IssueReporter$1.loggerFor('wazo-ws');
8345
+ const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
8292
8346
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
8293
8347
 
8294
8348
  class WebSocketClient extends Emitter {
@@ -8337,24 +8391,24 @@ class WebSocketClient extends Emitter {
8337
8391
  }
8338
8392
 
8339
8393
  connect() {
8340
- logger$8.info('connect method started', { host: this.host, token: this.token });
8394
+ logger$4.info('connect method started', { host: this.host, token: this.token });
8341
8395
  this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
8342
8396
  if (this.options.binaryType) {
8343
8397
  this.socket.binaryType = this.options.binaryType;
8344
8398
  }
8345
8399
 
8346
8400
  this.socket.onopen = () => {
8347
- logger$8.info('on Wazo WS open', { method: 'connect', host: this.host });
8348
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
8401
+ logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
8402
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
8349
8403
  };
8350
8404
 
8351
8405
  this.socket.onerror = event => {
8352
- logger$8.error('on Wazo WS error', event.target);
8353
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
8406
+ logger$4.error('on Wazo WS error', event.target);
8407
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
8354
8408
  };
8355
8409
 
8356
8410
  this.socket.onmessage = (event ) => {
8357
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
8411
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
8358
8412
 
8359
8413
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
8360
8414
  let { name } = message;
@@ -8379,7 +8433,7 @@ class WebSocketClient extends Emitter {
8379
8433
 
8380
8434
  this.socket.onclose = event => {
8381
8435
  // Can't be converted to JSON (circular structure)
8382
- logger$8.info('on Wazo WS close', {
8436
+ logger$4.info('on Wazo WS close', {
8383
8437
  reason: event.reason,
8384
8438
  code: event.code,
8385
8439
  readyState: event.target.readyState,
@@ -8387,22 +8441,22 @@ class WebSocketClient extends Emitter {
8387
8441
  token: this.token,
8388
8442
  });
8389
8443
  this.initialized = false;
8390
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
8444
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
8391
8445
 
8392
8446
  switch (event.code) {
8393
8447
  case 4002:
8394
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
8448
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
8395
8449
  break;
8396
8450
  }
8397
8451
  };
8398
8452
 
8399
8453
  this.socket.onerror = event => {
8400
- logger$8.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8454
+ logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8401
8455
  };
8402
8456
  }
8403
8457
 
8404
8458
  close(force = false) {
8405
- logger$8.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8459
+ logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8406
8460
 
8407
8461
  if (!this.socket) {
8408
8462
  return;
@@ -8420,7 +8474,7 @@ class WebSocketClient extends Emitter {
8420
8474
 
8421
8475
  updateToken(token ) {
8422
8476
  this.token = token;
8423
- logger$8.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8477
+ logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8424
8478
 
8425
8479
  if (this.socket) {
8426
8480
  // If still connected, send the token to the WS
@@ -8438,7 +8492,7 @@ class WebSocketClient extends Emitter {
8438
8492
  }
8439
8493
 
8440
8494
  startHeartbeat() {
8441
- logger$8.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8495
+ logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8442
8496
 
8443
8497
  if (!this.socket) {
8444
8498
  this.heartbeat.stop();
@@ -8452,7 +8506,7 @@ class WebSocketClient extends Emitter {
8452
8506
  }
8453
8507
 
8454
8508
  stopHeartbeat() {
8455
- logger$8.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8509
+ logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8456
8510
 
8457
8511
  this.heartbeat.stop();
8458
8512
  }
@@ -8482,7 +8536,7 @@ class WebSocketClient extends Emitter {
8482
8536
  }
8483
8537
 
8484
8538
  reconnect(reason ) {
8485
- logger$8.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8539
+ logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8486
8540
  if (!this.socket) {
8487
8541
  return;
8488
8542
  }
@@ -8507,7 +8561,7 @@ class WebSocketClient extends Emitter {
8507
8561
  break;
8508
8562
  case 'start':
8509
8563
  this.initialized = true;
8510
- this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
8564
+ this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
8511
8565
  break;
8512
8566
  default:
8513
8567
  this.eventEmitter.emit('message', message);
@@ -8538,7 +8592,7 @@ class WebSocketClient extends Emitter {
8538
8592
  this.close();
8539
8593
  }
8540
8594
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
8541
- logger$8.log('Wazo WS url computed to reconnect', { url });
8595
+ logger$4.log('Wazo WS url computed to reconnect', { url });
8542
8596
 
8543
8597
  return url;
8544
8598
  }
@@ -8546,15 +8600,15 @@ class WebSocketClient extends Emitter {
8546
8600
  _onHeartbeat(message ) {
8547
8601
  if (message.payload === 'pong') {
8548
8602
  this.heartbeat.onHeartbeat();
8549
- logger$8.log('on heartbeat received from Wazo WS');
8603
+ logger$4.log('on heartbeat received from Wazo WS');
8550
8604
  }
8551
8605
  }
8552
8606
 
8553
8607
  async _onHeartbeatTimeout() {
8554
- logger$8.log('heartbeat timed out', { host: this.host, token: this.token });
8608
+ logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
8555
8609
 
8556
8610
  this.close();
8557
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
8611
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
8558
8612
 
8559
8613
  if (this.onHeartBeatTimeout) {
8560
8614
  this.onHeartBeatTimeout();
@@ -8629,11 +8683,12 @@ WebSocketClient.eventLists = [
8629
8683
  AGENT_UNPAUSED,
8630
8684
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8631
8685
  CONFERENCE_ADHOC_DELETED,
8686
+ MEETING_USER_PROGRESS,
8632
8687
  ];
8633
8688
 
8634
8689
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8635
8690
  __proto__: null,
8636
- SOCKET_EVENTS: SOCKET_EVENTS$1,
8691
+ SOCKET_EVENTS: SOCKET_EVENTS,
8637
8692
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
8638
8693
  FAVORITE_ADDED: FAVORITE_ADDED,
8639
8694
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -8699,6 +8754,7 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8699
8754
  AGENT_UNPAUSED: AGENT_UNPAUSED,
8700
8755
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
8701
8756
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
8757
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
8702
8758
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
8703
8759
  'default': WebSocketClient
8704
8760
  });
@@ -8865,7 +8921,7 @@ class NotificationOptions {
8865
8921
 
8866
8922
 
8867
8923
  // Represents a conference room, like `9000`.
8868
- class Room$1 {
8924
+ class Room {
8869
8925
 
8870
8926
 
8871
8927
 
@@ -8886,7 +8942,7 @@ class Room$1 {
8886
8942
  }
8887
8943
 
8888
8944
  connect(callSession ) {
8889
- return new Room$1({ ...this, connectedCallSession: callSession });
8945
+ return new Room({ ...this, connectedCallSession: callSession });
8890
8946
  }
8891
8947
 
8892
8948
  has(callSession ) {
@@ -8895,7 +8951,7 @@ class Room$1 {
8895
8951
 
8896
8952
  addParticipant(uuid , extension , talking = null) {
8897
8953
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
8898
- return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
8954
+ return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
8899
8955
  }
8900
8956
 
8901
8957
  return this;
@@ -8914,7 +8970,7 @@ class Room$1 {
8914
8970
  updatedParticipants.push(participant);
8915
8971
  }
8916
8972
 
8917
- return new Room$1({ ...this, participants: updatedParticipants });
8973
+ return new Room({ ...this, participants: updatedParticipants });
8918
8974
  }
8919
8975
 
8920
8976
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -8930,7 +8986,7 @@ class Room$1 {
8930
8986
  updatedParticipants.push(participant);
8931
8987
  }
8932
8988
 
8933
- return new Room$1({ ...this, participants: updatedParticipants });
8989
+ return new Room({ ...this, participants: updatedParticipants });
8934
8990
  }
8935
8991
 
8936
8992
  hasCallWithId(id ) {
@@ -8938,18 +8994,18 @@ class Room$1 {
8938
8994
  }
8939
8995
 
8940
8996
  disconnect() {
8941
- return new Room$1({ ...this, connectedCallSession: null });
8997
+ return new Room({ ...this, connectedCallSession: null });
8942
8998
  }
8943
8999
 
8944
9000
  removeParticipantWithUUID(uuid ) {
8945
- return new Room$1({
9001
+ return new Room({
8946
9002
  ...this,
8947
9003
  participants: this.participants.filter(participant => participant.uuid !== uuid),
8948
9004
  });
8949
9005
  }
8950
9006
 
8951
9007
  removeParticipantWithExtension(extension ) {
8952
- return new Room$1({
9008
+ return new Room({
8953
9009
  ...this,
8954
9010
  participants: this.participants.filter(participant => participant.extension !== extension),
8955
9011
  });
@@ -8960,7 +9016,7 @@ class Room$1 {
8960
9016
  }
8961
9017
 
8962
9018
  static newFrom(room ) {
8963
- return newFrom(room, Room$1);
9019
+ return newFrom(room, Room);
8964
9020
  }
8965
9021
  }
8966
9022
 
@@ -9103,8 +9159,8 @@ const ON_CALL_FAILED = 'onCallFailed';
9103
9159
  const ON_CALL_ENDED = 'onCallEnded';
9104
9160
  const ON_CALL_ENDING = 'onCallEnding';
9105
9161
  const ON_MESSAGE = 'onMessage';
9106
- const ON_REINVITE = 'reinvite';
9107
- const ON_TRACK = 'onTrack';
9162
+ const ON_REINVITE$1 = 'reinvite';
9163
+ const ON_TRACK$1 = 'onTrack';
9108
9164
  const ON_AUDIO_STREAM = 'onAudioStream';
9109
9165
  const ON_VIDEO_STREAM = 'onVideoStream';
9110
9166
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -9119,15 +9175,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
9119
9175
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
9120
9176
  const ON_CALL_ERROR = 'onCallError';
9121
9177
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
9122
- const ON_NETWORK_STATS = 'onNetworkStats';
9178
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
9123
9179
  const ON_CHAT = 'phone/ON_CHAT';
9124
9180
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9125
- const ON_DISCONNECTED = 'onDisconnected';
9181
+ const ON_DISCONNECTED$1 = 'onDisconnected';
9126
9182
 
9127
9183
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9128
9184
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
9129
9185
 
9130
- const events = [
9186
+ const events$1 = [
9131
9187
  ON_USER_AGENT,
9132
9188
  ON_REGISTERED,
9133
9189
  ON_UNREGISTERED,
@@ -9145,8 +9201,8 @@ const events = [
9145
9201
  ON_CALL_FAILED,
9146
9202
  ON_CALL_ENDED,
9147
9203
  ON_MESSAGE,
9148
- ON_REINVITE,
9149
- ON_TRACK,
9204
+ ON_REINVITE$1,
9205
+ ON_TRACK$1,
9150
9206
  ON_AUDIO_STREAM,
9151
9207
  ON_VIDEO_STREAM,
9152
9208
  ON_REMOVE_STREAM,
@@ -9161,11 +9217,11 @@ const events = [
9161
9217
  ON_CALL_ERROR,
9162
9218
  ON_CHAT,
9163
9219
  ON_SIGNAL,
9164
- ON_NETWORK_STATS,
9165
- ON_DISCONNECTED,
9220
+ ON_NETWORK_STATS$1,
9221
+ ON_DISCONNECTED$1,
9166
9222
  ];
9167
9223
 
9168
- const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
9224
+ const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
9169
9225
 
9170
9226
  class WebRTCPhone extends Emitter {
9171
9227
 
@@ -9238,7 +9294,7 @@ class WebRTCPhone extends Emitter {
9238
9294
  }).catch(error => {
9239
9295
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
9240
9296
  console.error('register error', error, error.message, error.stack);
9241
- logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
9297
+ logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
9242
9298
  });
9243
9299
  }
9244
9300
 
@@ -9253,7 +9309,7 @@ class WebRTCPhone extends Emitter {
9253
9309
  if (!this.client) {
9254
9310
  return;
9255
9311
  }
9256
- logger$7.info('WebRTC phone stop');
9312
+ logger$5.info('WebRTC phone stop');
9257
9313
  this.client.stop();
9258
9314
  }
9259
9315
 
@@ -9268,7 +9324,7 @@ class WebRTCPhone extends Emitter {
9268
9324
  async sendReinvite(callSession , constraints = null, conference = false,
9269
9325
  audioOnly = false, iceRestart = false) {
9270
9326
  const sipSession = this.findSipSession(callSession);
9271
- logger$7.info('WebRTC phone - send reinvite', {
9327
+ logger$5.info('WebRTC phone - send reinvite', {
9272
9328
  sessionId: sipSession ? sipSession.id : null,
9273
9329
  constraints,
9274
9330
  audioOnly,
@@ -9305,7 +9361,7 @@ class WebRTCPhone extends Emitter {
9305
9361
  }
9306
9362
 
9307
9363
  startHeartbeat() {
9308
- logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9364
+ logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9309
9365
  if (!this.client || this.client.hasHeartbeat()) {
9310
9366
  return;
9311
9367
  }
@@ -9314,7 +9370,7 @@ class WebRTCPhone extends Emitter {
9314
9370
  }
9315
9371
 
9316
9372
  stopHeartbeat() {
9317
- logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9373
+ logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9318
9374
  if (!this.client) {
9319
9375
  return;
9320
9376
  }
@@ -9331,7 +9387,7 @@ class WebRTCPhone extends Emitter {
9331
9387
  }
9332
9388
 
9333
9389
  reconnect() {
9334
- logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
9390
+ logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
9335
9391
  if (!this.client) {
9336
9392
  return;
9337
9393
  }
@@ -9372,10 +9428,15 @@ class WebRTCPhone extends Emitter {
9372
9428
  return false;
9373
9429
  }
9374
9430
 
9375
- logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9431
+ logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9376
9432
 
9377
9433
  this.client.downgradeToAudio(sipSession);
9378
9434
 
9435
+ if (callSession) {
9436
+ callSession.cameraEnabled = false;
9437
+ this._updateCallSession(callSession);
9438
+ }
9439
+
9379
9440
  if (withMessage) {
9380
9441
  this._sendReinviteMessage(callSession, false);
9381
9442
  }
@@ -9390,7 +9451,7 @@ class WebRTCPhone extends Emitter {
9390
9451
  return Promise.resolve(false);
9391
9452
  }
9392
9453
 
9393
- logger$7.info('Upgrade to video', {
9454
+ logger$5.info('Upgrade to video', {
9394
9455
  id: callSession ? callSession.getId() : null,
9395
9456
  constraints,
9396
9457
  isConference,
@@ -9403,6 +9464,11 @@ class WebRTCPhone extends Emitter {
9403
9464
 
9404
9465
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
9405
9466
 
9467
+ if (callSession) {
9468
+ callSession.cameraEnabled = true;
9469
+ this._updateCallSession(callSession);
9470
+ }
9471
+
9406
9472
  // If no stream is returned, it means we have to reinvite
9407
9473
  if (!newStream) {
9408
9474
  return true;
@@ -9425,7 +9491,7 @@ class WebRTCPhone extends Emitter {
9425
9491
 
9426
9492
  _sendReinviteMessage(callSession , isUpgrade ) {
9427
9493
  const sipSession = this.findSipSession(callSession);
9428
- logger$7.info('Sending reinvite message', {
9494
+ logger$5.info('Sending reinvite message', {
9429
9495
  id: callSession ? callSession.getId() : null,
9430
9496
  isUpgrade,
9431
9497
  });
@@ -9451,11 +9517,14 @@ class WebRTCPhone extends Emitter {
9451
9517
  // Monkey patch to know when canceled with the CANCEL message
9452
9518
  const onCancel = sipSession._onCancel.bind(sipSession);
9453
9519
  sipSession._onCancel = (message ) => {
9454
- logger$7.trace('on sip session canceled', { callId: message.callId });
9520
+ logger$5.trace('on sip session canceled', { callId: message.callId });
9455
9521
 
9456
9522
  onCancel(message);
9457
9523
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9458
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9524
+ const callSession = this._createCallSession(sipSession);
9525
+ delete this.callSessions[callSession.getId()];
9526
+
9527
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9459
9528
  };
9460
9529
  } else if (sipSession instanceof Invitation) {
9461
9530
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9476,17 +9545,19 @@ class WebRTCPhone extends Emitter {
9476
9545
  this.audioOutputVolume,
9477
9546
  );
9478
9547
  case SessionState.Terminating:
9479
- logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9548
+ logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9480
9549
 
9481
9550
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9482
9551
 
9483
9552
  break;
9484
9553
  case SessionState.Terminated: {
9485
- logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9554
+ logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9486
9555
 
9556
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9557
+ const callSession = this._createCallSession(sipSession);
9487
9558
  const wasCurrentSession = this._onCallTerminated(sipSession);
9488
9559
 
9489
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9560
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9490
9561
  }
9491
9562
  }
9492
9563
  });
@@ -9502,7 +9573,7 @@ class WebRTCPhone extends Emitter {
9502
9573
  const [stream] = event.streams;
9503
9574
  const kind = event && event.track && event.track.kind;
9504
9575
 
9505
- logger$7.info('on track stream called on the peer connection', {
9576
+ logger$5.info('on track stream called on the peer connection', {
9506
9577
  callId: this.getSipSessionId(sipSession),
9507
9578
  streamId: stream ? stream.id : null,
9508
9579
  tracks: stream ? stream.getTracks() : null,
@@ -9522,7 +9593,7 @@ class WebRTCPhone extends Emitter {
9522
9593
  };
9523
9594
 
9524
9595
  peerConnection.onremovestream = event => {
9525
- logger$7.info('on remove stream called on the peer connection', {
9596
+ logger$5.info('on remove stream called on the peer connection', {
9526
9597
  id: event.stream.id,
9527
9598
  tracks: event.stream.getTracks(),
9528
9599
  });
@@ -9532,7 +9603,7 @@ class WebRTCPhone extends Emitter {
9532
9603
  }
9533
9604
 
9534
9605
  async startScreenSharing(constraints , callSession ) {
9535
- logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9606
+ logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9536
9607
 
9537
9608
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9538
9609
  if (!screenShareStream) {
@@ -9572,7 +9643,7 @@ class WebRTCPhone extends Emitter {
9572
9643
  return;
9573
9644
  }
9574
9645
 
9575
- logger$7.info('WebRTC phone - stop screen sharing', {
9646
+ logger$5.info('WebRTC phone - stop screen sharing', {
9576
9647
  restoreLocalStream,
9577
9648
  });
9578
9649
 
@@ -9628,24 +9699,26 @@ class WebRTCPhone extends Emitter {
9628
9699
  const pc = this.client.getPeerConnection(sipSessionId);
9629
9700
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9630
9701
 
9631
- logger$7.info('WebRTC phone - on screensharing', {
9702
+ logger$5.info('WebRTC phone - on screensharing', {
9632
9703
  hadVideo,
9633
9704
  id: this.getSipSessionId(sipSession),
9634
9705
  screenTrack,
9635
9706
  });
9636
9707
 
9637
- screenTrack.onended = () => {
9638
- logger$7.info('WebRTC phone - on screenshare ended', {
9639
- hadVideo,
9640
- id: this.getSipSessionId(sipSession),
9641
- screenTrack,
9642
- });
9708
+ if (screenTrack) {
9709
+ screenTrack.onended = () => {
9710
+ logger$5.info('WebRTC phone - on screenshare ended', {
9711
+ hadVideo,
9712
+ id: this.getSipSessionId(sipSession),
9713
+ screenTrack,
9714
+ });
9643
9715
 
9644
- this.eventEmitter.emit(
9645
- ON_SHARE_SCREEN_ENDING,
9646
- this._createCallSession(sipSession, callSession),
9647
- );
9648
- };
9716
+ this.eventEmitter.emit(
9717
+ ON_SHARE_SCREEN_ENDING,
9718
+ this._createCallSession(sipSession, callSession),
9719
+ );
9720
+ };
9721
+ }
9649
9722
 
9650
9723
  this.currentScreenShare = {
9651
9724
  stream: screenStream,
@@ -9665,7 +9738,7 @@ class WebRTCPhone extends Emitter {
9665
9738
  }
9666
9739
 
9667
9740
  _onCallAccepted(sipSession , cameraEnabled ) {
9668
- logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9741
+ logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9669
9742
 
9670
9743
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9671
9744
  this.currentSipSession = sipSession;
@@ -9683,7 +9756,7 @@ class WebRTCPhone extends Emitter {
9683
9756
  }
9684
9757
 
9685
9758
  changeAudioDevice(id ) {
9686
- logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9759
+ logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9687
9760
  this.audioOutputDeviceId = id;
9688
9761
  this.client.changeAudioOutputDevice(id);
9689
9762
  }
@@ -9693,14 +9766,14 @@ class WebRTCPhone extends Emitter {
9693
9766
  }
9694
9767
 
9695
9768
  changeRingDevice(id ) {
9696
- logger$7.info('WebRTC phone - changing ring device', { id });
9769
+ logger$5.info('WebRTC phone - changing ring device', { id });
9697
9770
 
9698
9771
  this.audioRingDeviceId = id;
9699
9772
  }
9700
9773
 
9701
9774
  // volume is a value between 0 and 1
9702
9775
  changeAudioVolume(volume ) {
9703
- logger$7.info('WebRTC phone - changing audio volume', { volume });
9776
+ logger$5.info('WebRTC phone - changing audio volume', { volume });
9704
9777
 
9705
9778
  this.audioOutputVolume = volume;
9706
9779
  this.client.changeAudioOutputVolume(volume);
@@ -9708,31 +9781,31 @@ class WebRTCPhone extends Emitter {
9708
9781
 
9709
9782
  // volume is a value between 0 and 1
9710
9783
  changeRingVolume(volume ) {
9711
- logger$7.info('WebRTC phone - changing ring volume', { volume });
9784
+ logger$5.info('WebRTC phone - changing ring volume', { volume });
9712
9785
 
9713
9786
  this.audioRingVolume = volume;
9714
9787
  }
9715
9788
 
9716
9789
  changeAudioInputDevice(id ) {
9717
- logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9790
+ logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9718
9791
 
9719
9792
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9720
9793
  }
9721
9794
 
9722
9795
  changeVideoInputDevice(id ) {
9723
- logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9796
+ logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9724
9797
 
9725
9798
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9726
9799
  }
9727
9800
 
9728
9801
  changeSessionVideoInputDevice(id ) {
9729
- logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9802
+ logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9730
9803
 
9731
9804
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9732
9805
  }
9733
9806
 
9734
9807
  _onCallTerminated(sipSession ) {
9735
- logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9808
+ logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9736
9809
 
9737
9810
  const callSession = this._createCallSession(sipSession);
9738
9811
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -9766,7 +9839,7 @@ class WebRTCPhone extends Emitter {
9766
9839
  const hasIncomingCallSession = this.hasIncomingCallSession();
9767
9840
 
9768
9841
  // Re-trigger incoming call event for remaining incoming calls
9769
- logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9842
+ logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9770
9843
  sipId: sipSession.id,
9771
9844
  shouldRetrigger,
9772
9845
  hasIncomingCallSession,
@@ -9857,37 +9930,37 @@ class WebRTCPhone extends Emitter {
9857
9930
 
9858
9931
  // Deprecated
9859
9932
  getLocalStreamForCall(callSession ) {
9860
- logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9933
+ logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9861
9934
 
9862
9935
  return this.getLocalStream(callSession);
9863
9936
  }
9864
9937
 
9865
9938
  // Deprecated
9866
9939
  getRemoteStreamForCall(callSession ) {
9867
- logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9940
+ logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9868
9941
 
9869
9942
  return this.getRemoteVideoStream(callSession);
9870
9943
  }
9871
9944
 
9872
9945
  getRemoteStreamsForCall(callSession ) {
9873
- logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9946
+ logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9874
9947
 
9875
9948
  return this.getRemoteStream(callSession);
9876
9949
  }
9877
9950
 
9878
9951
  accept(callSession , cameraEnabled ) {
9879
- logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9952
+ logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9880
9953
  if (this.currentSipSession) {
9881
9954
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9882
9955
  }
9883
9956
 
9884
9957
  if (!callSession) {
9885
- logger$7.warn('no CallSession to accept.');
9958
+ logger$5.warn('no CallSession to accept.');
9886
9959
  return Promise.resolve(null);
9887
9960
  }
9888
9961
 
9889
9962
  if (callSession.getId() in this.acceptedSessions) {
9890
- logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9963
+ logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9891
9964
  return Promise.resolve(callSession.sipCallId);
9892
9965
  }
9893
9966
 
@@ -9899,24 +9972,24 @@ class WebRTCPhone extends Emitter {
9899
9972
  const sipSession = this.client.getSipSession(callSession.getId());
9900
9973
  if (sipSession) {
9901
9974
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
9902
- logger$7.warn('Trying to answer a terminated sipSession.');
9975
+ logger$5.warn('Trying to answer a terminated sipSession.');
9903
9976
 
9904
9977
  return Promise.resolve(null);
9905
9978
  }
9906
9979
 
9907
- logger$7.info('accept call, session found', { sipId: sipSession.id });
9980
+ logger$5.info('accept call, session found', { sipId: sipSession.id });
9908
9981
 
9909
9982
  // $FlowFixMe
9910
9983
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9911
9984
  return callSession.sipCallId;
9912
9985
  }).catch(e => {
9913
- logger$7.error(e);
9986
+ logger$5.error(e);
9914
9987
  this.endCurrentCall(callSession);
9915
9988
  throw e;
9916
9989
  });
9917
9990
  }
9918
9991
 
9919
- logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9992
+ logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9920
9993
 
9921
9994
  return Promise.resolve(null);
9922
9995
  }
@@ -9926,7 +9999,7 @@ class WebRTCPhone extends Emitter {
9926
9999
  }
9927
10000
 
9928
10001
  async reject(callSession ) {
9929
- logger$7.info('reject WebRTC called', { id: callSession.getId() });
10002
+ logger$5.info('reject WebRTC called', { id: callSession.getId() });
9930
10003
 
9931
10004
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9932
10005
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9938,14 +10011,14 @@ class WebRTCPhone extends Emitter {
9938
10011
 
9939
10012
  const sipSession = this.findSipSession(callSession);
9940
10013
  if (sipSession) {
9941
- logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
10014
+ logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9942
10015
 
9943
10016
  this.client.hangup(sipSession);
9944
10017
  }
9945
10018
  }
9946
10019
 
9947
10020
  async ignore(callSession ) {
9948
- logger$7.info('WebRTC ignore', { id: callSession.getId() });
10021
+ logger$5.info('WebRTC ignore', { id: callSession.getId() });
9949
10022
 
9950
10023
  // kill the ring
9951
10024
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9957,14 +10030,14 @@ class WebRTCPhone extends Emitter {
9957
10030
  const sipSession = this.findSipSession(callSession);
9958
10031
 
9959
10032
  if (sipSession) {
9960
- logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
10033
+ logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9961
10034
 
9962
10035
  return this.client.atxfer(sipSession);
9963
10036
  }
9964
10037
  }
9965
10038
 
9966
10039
  hold(callSession , withEvent = true, isConference = false) {
9967
- logger$7.info('WebRTC hold', { id: callSession.getId() });
10040
+ logger$5.info('WebRTC hold', { id: callSession.getId() });
9968
10041
 
9969
10042
  const sipSession = this.findSipSession(callSession);
9970
10043
 
@@ -9979,18 +10052,18 @@ class WebRTCPhone extends Emitter {
9979
10052
  }
9980
10053
 
9981
10054
  resume(callSession , isConference = false, withEvent = true) {
9982
- logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
10055
+ logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9983
10056
 
9984
10057
  const sipSession = this.findSipSession(callSession);
9985
10058
  if (!sipSession) {
9986
10059
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9987
10060
  }
9988
10061
 
9989
- logger$7.info('WebRTC resuming', { sipId: sipSession.id });
10062
+ logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9990
10063
 
9991
10064
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9992
10065
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9993
- logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
10066
+ logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9994
10067
  this.holdSipSession(this.currentSipSession, callSession);
9995
10068
  }
9996
10069
 
@@ -10015,7 +10088,7 @@ class WebRTCPhone extends Emitter {
10015
10088
  const sessionId = this.getSipSessionId(sipSession);
10016
10089
  const hasVideo = this.client.hasLocalVideo(sessionId);
10017
10090
 
10018
- logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10091
+ logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10019
10092
 
10020
10093
  // Stop screenshre if needed
10021
10094
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -10046,7 +10119,7 @@ class WebRTCPhone extends Emitter {
10046
10119
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
10047
10120
  }
10048
10121
  const sessionId = this.getSipSessionId(sipSession);
10049
- logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
10122
+ logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
10050
10123
 
10051
10124
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
10052
10125
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -10090,14 +10163,14 @@ class WebRTCPhone extends Emitter {
10090
10163
  }
10091
10164
 
10092
10165
  mute(callSession , withEvent = true) {
10093
- logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10166
+ logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10094
10167
 
10095
10168
  const sipSession = this.findSipSession(callSession);
10096
10169
  if (!sipSession) {
10097
10170
  return;
10098
10171
  }
10099
10172
 
10100
- logger$7.info('WebRTC muting', { sipId: sipSession.id });
10173
+ logger$5.info('WebRTC muting', { sipId: sipSession.id });
10101
10174
  this.client.mute(sipSession);
10102
10175
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
10103
10176
 
@@ -10111,14 +10184,14 @@ class WebRTCPhone extends Emitter {
10111
10184
  }
10112
10185
 
10113
10186
  unmute(callSession , withEvent = true) {
10114
- logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10187
+ logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10115
10188
 
10116
10189
  const sipSession = this.findSipSession(callSession);
10117
10190
  if (!sipSession) {
10118
10191
  return;
10119
10192
  }
10120
10193
 
10121
- logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
10194
+ logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
10122
10195
  this.client.unmute(sipSession);
10123
10196
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
10124
10197
 
@@ -10145,7 +10218,7 @@ class WebRTCPhone extends Emitter {
10145
10218
  if (!sipSession) {
10146
10219
  return;
10147
10220
  }
10148
- logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
10221
+ logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
10149
10222
 
10150
10223
  this.client.toggleCameraOn(sipSession);
10151
10224
 
@@ -10157,7 +10230,7 @@ class WebRTCPhone extends Emitter {
10157
10230
  if (!sipSession) {
10158
10231
  return;
10159
10232
  }
10160
- logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
10233
+ logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
10161
10234
 
10162
10235
  this.client.toggleCameraOff(sipSession);
10163
10236
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -10169,7 +10242,7 @@ class WebRTCPhone extends Emitter {
10169
10242
  return;
10170
10243
  }
10171
10244
 
10172
- logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
10245
+ logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
10173
10246
  this.client.sendDTMF(sipSession, tone);
10174
10247
  }
10175
10248
 
@@ -10177,7 +10250,7 @@ class WebRTCPhone extends Emitter {
10177
10250
  // @TODO: line is not used here
10178
10251
  async makeCall(number , line , cameraEnabled ,
10179
10252
  audioOnly = false, conference = false) {
10180
- logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
10253
+ logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
10181
10254
  if (!number) {
10182
10255
  return Promise.resolve(null);
10183
10256
  }
@@ -10187,7 +10260,7 @@ class WebRTCPhone extends Emitter {
10187
10260
  }
10188
10261
  if (this.currentSipSession) {
10189
10262
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10190
- logger$7.warn('Unable to hold current session when making another call', e);
10263
+ logger$5.warn('Unable to hold current session when making another call', e);
10191
10264
  });
10192
10265
  }
10193
10266
 
@@ -10197,7 +10270,7 @@ class WebRTCPhone extends Emitter {
10197
10270
  this._bindEvents(sipSession);
10198
10271
  } catch (error) {
10199
10272
  console.warn(error);
10200
- logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10273
+ logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10201
10274
  return Promise.resolve(null);
10202
10275
  }
10203
10276
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -10225,7 +10298,7 @@ class WebRTCPhone extends Emitter {
10225
10298
  return;
10226
10299
  }
10227
10300
 
10228
- logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
10301
+ logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
10229
10302
 
10230
10303
  this.client.transfer(sipSession, target);
10231
10304
  }
@@ -10234,7 +10307,7 @@ class WebRTCPhone extends Emitter {
10234
10307
  const sipSession = this.client.getSipSession(source.sipCallId);
10235
10308
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
10236
10309
 
10237
- logger$7.info('WebRTC indirect transfer', {
10310
+ logger$5.info('WebRTC indirect transfer', {
10238
10311
  sipId: sipSession ? sipSession.id : null,
10239
10312
  target: sipSessionTarget ? sipSessionTarget.id : null,
10240
10313
  });
@@ -10273,7 +10346,7 @@ class WebRTCPhone extends Emitter {
10273
10346
  return false;
10274
10347
  }
10275
10348
 
10276
- logger$7.info('WebRTC hangup', { sipId: sipSession.id });
10349
+ logger$5.info('WebRTC hangup', { sipId: sipSession.id });
10277
10350
 
10278
10351
  const sipSessionId = this.getSipSessionId(sipSession);
10279
10352
 
@@ -10319,7 +10392,7 @@ class WebRTCPhone extends Emitter {
10319
10392
  endCurrentCall(callSession ) {
10320
10393
  const isCurrent = this.isCurrentCallSipSession(callSession);
10321
10394
 
10322
- logger$7.info('Ending current call', {
10395
+ logger$5.info('Ending current call', {
10323
10396
  id: callSession ? callSession.getId() : null,
10324
10397
  isCurrent,
10325
10398
  });
@@ -10343,7 +10416,7 @@ class WebRTCPhone extends Emitter {
10343
10416
  }
10344
10417
 
10345
10418
  async close() {
10346
- logger$7.info('WebRTC close');
10419
+ logger$5.info('WebRTC close');
10347
10420
 
10348
10421
  try {
10349
10422
  await Promise.race([
@@ -10351,7 +10424,7 @@ class WebRTCPhone extends Emitter {
10351
10424
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
10352
10425
  ]);
10353
10426
  } catch (e) {
10354
- logger$7.error('WebRTC close, unregister error', e);
10427
+ logger$5.error('WebRTC close, unregister error', e);
10355
10428
  }
10356
10429
 
10357
10430
  this.client.close();
@@ -10369,12 +10442,12 @@ class WebRTCPhone extends Emitter {
10369
10442
  }
10370
10443
 
10371
10444
  enableRinging() {
10372
- logger$7.info('WebRTC enable ringing');
10445
+ logger$5.info('WebRTC enable ringing');
10373
10446
  this.ringingEnabled = true;
10374
10447
  }
10375
10448
 
10376
10449
  disableRinging() {
10377
- logger$7.info('WebRTC disable ringing');
10450
+ logger$5.info('WebRTC disable ringing');
10378
10451
  this.ringingEnabled = false;
10379
10452
  }
10380
10453
 
@@ -10414,7 +10487,7 @@ class WebRTCPhone extends Emitter {
10414
10487
 
10415
10488
  // Deprecated
10416
10489
  getLocalMediaStream(callSession ) {
10417
- logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10490
+ logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10418
10491
  return this.getLocalStream(callSession);
10419
10492
  }
10420
10493
 
@@ -10434,6 +10507,10 @@ class WebRTCPhone extends Emitter {
10434
10507
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
10435
10508
  }
10436
10509
 
10510
+ getRemoteVideoStreamFromPc(callSession ) {
10511
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10512
+ }
10513
+
10437
10514
  hasRemoteVideo(callSession ) {
10438
10515
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
10439
10516
  }
@@ -10452,7 +10529,7 @@ class WebRTCPhone extends Emitter {
10452
10529
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10453
10530
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10454
10531
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10455
- logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10532
+ logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10456
10533
 
10457
10534
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10458
10535
  this.incomingSessions.push(callSession.getId());
@@ -10475,7 +10552,7 @@ class WebRTCPhone extends Emitter {
10475
10552
  });
10476
10553
 
10477
10554
  this.client.on(this.client.ON_REINVITE, (...args) => {
10478
- logger$7.info('WebRTC on reinvite', {
10555
+ logger$5.info('WebRTC on reinvite', {
10479
10556
  sessionId: args[0].id,
10480
10557
  inviteId: args[1].id,
10481
10558
  updatedCalleeName: args[2],
@@ -10495,7 +10572,7 @@ class WebRTCPhone extends Emitter {
10495
10572
  });
10496
10573
 
10497
10574
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10498
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10575
+ logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10499
10576
 
10500
10577
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10501
10578
 
@@ -10506,22 +10583,22 @@ class WebRTCPhone extends Emitter {
10506
10583
  this.client.on('ended', () => {});
10507
10584
 
10508
10585
  this.client.on(this.client.ON_ERROR, e => {
10509
- logger$7.error('WebRTC error', e);
10586
+ logger$5.error('WebRTC error', e);
10510
10587
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10511
10588
  });
10512
10589
 
10513
10590
  this.client.on(this.client.UNREGISTERED, () => {
10514
- logger$7.info('WebRTC unregistered');
10591
+ logger$5.info('WebRTC unregistered');
10515
10592
  this.eventEmitter.emit(ON_UNREGISTERED);
10516
10593
  });
10517
10594
 
10518
10595
  this.client.on(this.client.ON_DISCONNECTED, () => {
10519
- logger$7.info('WebRTC disconnected');
10520
- this.eventEmitter.emit(ON_DISCONNECTED);
10596
+ logger$5.info('WebRTC disconnected');
10597
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
10521
10598
  });
10522
10599
 
10523
10600
  this.client.on(this.client.REGISTERED, () => {
10524
- logger$7.info('WebRTC registered', {
10601
+ logger$5.info('WebRTC registered', {
10525
10602
  shouldSendReinvite: this.shouldSendReinvite,
10526
10603
  state: this.currentSipSession ? this.currentSipSession.state : null,
10527
10604
  currentSipSession: !!this.currentSipSession,
@@ -10534,23 +10611,27 @@ class WebRTCPhone extends Emitter {
10534
10611
  if (this.shouldSendReinvite && this.currentSipSession
10535
10612
  && this.currentSipSession.state === SessionState.Established) {
10536
10613
  this.shouldSendReinvite = false;
10614
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
10615
+ const isConference = pc ? pc.sfu : false;
10616
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
10617
+
10537
10618
  try {
10538
10619
  // Send reinvite with iceRestart
10539
- this.sendReinvite(this.currentCallSession, null, false, false, true);
10620
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10540
10621
  } catch (e) {
10541
- logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10622
+ logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10542
10623
  }
10543
10624
  }
10544
10625
  });
10545
10626
 
10546
10627
  this.client.on(this.client.CONNECTED, () => {
10547
- logger$7.info('WebRTC client connected');
10628
+ logger$5.info('WebRTC client connected');
10548
10629
 
10549
10630
  this.stopHeartbeat();
10550
10631
  });
10551
10632
 
10552
10633
  this.client.on(this.client.DISCONNECTED, () => {
10553
- logger$7.info('WebRTC client disconnected');
10634
+ logger$5.info('WebRTC client disconnected');
10554
10635
 
10555
10636
  this.eventEmitter.emit(ON_UNREGISTERED);
10556
10637
 
@@ -10564,7 +10645,7 @@ class WebRTCPhone extends Emitter {
10564
10645
  });
10565
10646
 
10566
10647
  this.client.on(this.client.ON_TRACK, (session, event) => {
10567
- this.eventEmitter.emit(ON_TRACK, session, event);
10648
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
10568
10649
  });
10569
10650
 
10570
10651
  this.client.on('onVideoInputChange', stream => {
@@ -10579,7 +10660,7 @@ class WebRTCPhone extends Emitter {
10579
10660
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10580
10661
  const callSession = this.getCallSession(this.getSipSessionId(session));
10581
10662
 
10582
- this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10663
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10583
10664
  });
10584
10665
 
10585
10666
  // Used when upgrading directly in screenshare mode
@@ -10588,7 +10669,7 @@ class WebRTCPhone extends Emitter {
10588
10669
  const localStream = this.client.getLocalStream(sipSessionId);
10589
10670
  const callSession = this.callSessions[sipSessionId];
10590
10671
 
10591
- logger$7.info('Updrading directly in screensharing mode', {
10672
+ logger$5.info('Updrading directly in screensharing mode', {
10592
10673
  sipSessionId,
10593
10674
  tracks: localStream ? localStream.getTracks() : null,
10594
10675
  });
@@ -10620,6 +10701,15 @@ class WebRTCPhone extends Emitter {
10620
10701
  return this.client.getSipSessionId(sipSession);
10621
10702
  }
10622
10703
 
10704
+ _updateCallSession(callSession ) {
10705
+ const sipSession = this.findSipSession(callSession);
10706
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10707
+
10708
+ if (sipSessionId) {
10709
+ this.callSessions[sipSessionId] = callSession;
10710
+ }
10711
+ }
10712
+
10623
10713
  _onMessage(message ) {
10624
10714
  if (!message || message.method !== 'MESSAGE') {
10625
10715
  return;
@@ -10757,8 +10847,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10757
10847
  ON_CALL_ENDED: ON_CALL_ENDED,
10758
10848
  ON_CALL_ENDING: ON_CALL_ENDING,
10759
10849
  ON_MESSAGE: ON_MESSAGE,
10760
- ON_REINVITE: ON_REINVITE,
10761
- ON_TRACK: ON_TRACK,
10850
+ ON_REINVITE: ON_REINVITE$1,
10851
+ ON_TRACK: ON_TRACK$1,
10762
10852
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10763
10853
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10764
10854
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10773,13 +10863,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10773
10863
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10774
10864
  ON_CALL_ERROR: ON_CALL_ERROR,
10775
10865
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10776
- ON_NETWORK_STATS: ON_NETWORK_STATS,
10866
+ ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10777
10867
  ON_CHAT: ON_CHAT,
10778
10868
  ON_SIGNAL: ON_SIGNAL,
10779
- ON_DISCONNECTED: ON_DISCONNECTED,
10869
+ ON_DISCONNECTED: ON_DISCONNECTED$1,
10780
10870
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10781
10871
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10782
- events: events,
10872
+ events: events$1,
10783
10873
  'default': WebRTCPhone
10784
10874
  });
10785
10875
 
@@ -10950,11 +11040,11 @@ var wazoWebsocket = {
10950
11040
  resolve();
10951
11041
  };
10952
11042
 
10953
- client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
11043
+ client.on(SOCKET_EVENTS.ON_ERROR, error => {
10954
11044
  handleError(`Connection error : ${error}`);
10955
11045
  });
10956
11046
 
10957
- client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
11047
+ client.on(SOCKET_EVENTS.ON_OPEN, () => {
10958
11048
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
10959
11049
  client.setOnHeartbeatTimeout(() => {
10960
11050
  handleError('No response to heartbeat');
@@ -11055,7 +11145,7 @@ var webrtc = {
11055
11145
  }),
11056
11146
  };
11057
11147
 
11058
- const parseCandidate = line => {
11148
+ const parseCandidate$1 = line => {
11059
11149
  let parts;
11060
11150
  // Parse both variants.
11061
11151
  if (line.indexOf('a=candidate:') === 0) {
@@ -11146,7 +11236,7 @@ var SymmetricNat = {
11146
11236
  }
11147
11237
 
11148
11238
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
11149
- const cand = parseCandidate(e.candidate.candidate);
11239
+ const cand = parseCandidate$1(e.candidate.candidate);
11150
11240
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
11151
11241
  candidates[cand.relatedPort].push(cand.port);
11152
11242
  } else if (!e.candidate) {
@@ -11214,7 +11304,7 @@ var iceIpv4 = {
11214
11304
  const rawCandidate = e.candidate.candidate;
11215
11305
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
11216
11306
  hasSrflxOrRelay = true;
11217
- const candidate = parseCandidate(e.candidate.candidate);
11307
+ const candidate = parseCandidate$1(e.candidate.candidate);
11218
11308
  ips.push(candidate.ip);
11219
11309
  }
11220
11310
  } else if (!e.candidate) {
@@ -11384,7 +11474,7 @@ const getCallableNumber = (number , country ) => {
11384
11474
  class InvalidSubscription extends Error {}
11385
11475
  class InvalidAuthorization extends Error {}
11386
11476
 
11387
- const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11477
+ const logger$7 = IssueReporter$1.loggerFor('simple-auth');
11388
11478
 
11389
11479
  class Auth {
11390
11480
 
@@ -11419,7 +11509,7 @@ class Auth {
11419
11509
  setApiClientId(this.clientId);
11420
11510
  setRefreshExpiration(this.expiration);
11421
11511
  setOnRefreshToken((token , session ) => {
11422
- logger$5.info('on refresh token done', { token });
11512
+ logger$7.info('on refresh token done', { token });
11423
11513
  setApiToken(token);
11424
11514
  Wazo.Websocket.updateToken(token);
11425
11515
 
@@ -11464,7 +11554,7 @@ class Auth {
11464
11554
  const rawSession = await getApiClient().auth.authenticate(token);
11465
11555
  return this._onAuthenticated(rawSession);
11466
11556
  } catch (e) {
11467
- logger$5.error('on validate token error', e);
11557
+ logger$7.error('on validate token error', e);
11468
11558
  console.warn(e);
11469
11559
  return false;
11470
11560
  }
@@ -11820,7 +11910,7 @@ class AdHocAPIConference {
11820
11910
 
11821
11911
  //
11822
11912
 
11823
- const logger$4 = IssueReporter$1.loggerFor('simple-phone');
11913
+ const logger$8 = IssueReporter$1.loggerFor('simple-phone');
11824
11914
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
11825
11915
  const protocolLogger = IssueReporter$1.loggerFor('sip');
11826
11916
 
@@ -11927,7 +12017,7 @@ class Phone extends Emitter {
11927
12017
  async disconnect() {
11928
12018
  if (this.phone) {
11929
12019
  if (this.phone.hasAnActiveCall()) {
11930
- logger$4.info('hangup call on disconnect');
12020
+ logger$8.info('hangup call on disconnect');
11931
12021
  // $FlowFixMe
11932
12022
  await this.phone.hangup();
11933
12023
  }
@@ -11950,13 +12040,13 @@ class Phone extends Emitter {
11950
12040
  }
11951
12041
 
11952
12042
  async hangup(callSession ) {
11953
- logger$4.info('hangup via simple phone', { callId: callSession.getId() });
12043
+ logger$8.info('hangup via simple phone', { callId: callSession.getId() });
11954
12044
 
11955
12045
  return this.phone && this.phone.hangup(callSession);
11956
12046
  }
11957
12047
 
11958
12048
  async accept(callSession , cameraEnabled ) {
11959
- logger$4.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
12049
+ logger$8.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
11960
12050
 
11961
12051
  return this.phone && this.phone.accept(callSession, cameraEnabled);
11962
12052
  }
@@ -11995,7 +12085,7 @@ class Phone extends Emitter {
11995
12085
  muteViaAPI(callSession ) {
11996
12086
  if (callSession && callSession.callId) {
11997
12087
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
11998
- logger$4.error('Mute via API, error', e);
12088
+ logger$8.error('Mute via API, error', e);
11999
12089
  });
12000
12090
  }
12001
12091
  }
@@ -12003,7 +12093,7 @@ class Phone extends Emitter {
12003
12093
  unmuteViaAPI(callSession ) {
12004
12094
  if (callSession && callSession.callId) {
12005
12095
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
12006
- logger$4.error('Unmute via API, error', e);
12096
+ logger$8.error('Unmute via API, error', e);
12007
12097
  });
12008
12098
  }
12009
12099
  }
@@ -12111,7 +12201,7 @@ class Phone extends Emitter {
12111
12201
 
12112
12202
  // @Deprecated
12113
12203
  getLocalMediaStream(callSession ) {
12114
- logger$4.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12204
+ logger$8.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12115
12205
 
12116
12206
  return this.phone && this.phone.getLocalStream(callSession);
12117
12207
  }
@@ -12134,24 +12224,29 @@ class Phone extends Emitter {
12134
12224
 
12135
12225
  // @Deprecated
12136
12226
  getRemoteStreamForCall(callSession ) {
12137
- logger$4.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12227
+ logger$8.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12138
12228
  return this.getRemoteStream(callSession);
12139
12229
  }
12140
12230
 
12141
12231
  // Returns remote streams directly from the peerConnection
12142
12232
  // @Deprecated
12143
12233
  getRemoteStreamsForCall(callSession ) {
12144
- logger$4.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12234
+ logger$8.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12145
12235
  return this.getLocalStream(callSession);
12146
12236
  }
12147
12237
 
12148
12238
  // @Deprecated
12149
12239
  getRemoteVideoStreamForCall(callSession ) {
12150
- logger$4.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12240
+ logger$8.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12151
12241
 
12152
12242
  return this.getRemoteVideoStream(callSession);
12153
12243
  }
12154
12244
 
12245
+ // Useful in a react-native environment when remoteMediaStream is not updated
12246
+ getRemoteVideoStreamFromPc(callSession ) {
12247
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
12248
+ }
12249
+
12155
12250
  hasVideo(callSession ) {
12156
12251
  return this.phone ? this.phone.hasVideo(callSession) : false;
12157
12252
  }
@@ -12203,7 +12298,7 @@ class Phone extends Emitter {
12203
12298
 
12204
12299
  _transferEvents() {
12205
12300
  this.unbind();
12206
- [...events$1, ...transportEvents].forEach(event => {
12301
+ [...events, ...transportEvents].forEach(event => {
12207
12302
  this.client.on(event, (...args) =>
12208
12303
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
12209
12304
  });
@@ -12225,10 +12320,10 @@ var Phone$1 = global.wazoTelephonyInstance;
12225
12320
 
12226
12321
  //
12227
12322
 
12228
- const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
12229
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
12323
+ const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
12324
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
12230
12325
 
12231
- const logger$3 = IssueReporter$1.loggerFor('simple-ws-client');
12326
+ const logger$9 = IssueReporter$1.loggerFor('simple-ws-client');
12232
12327
 
12233
12328
  class Websocket extends Emitter {
12234
12329
 
@@ -12242,9 +12337,9 @@ class Websocket extends Emitter {
12242
12337
  // $FlowFixMe
12243
12338
  this[key] = OTHER_EVENTS[key];
12244
12339
  });
12245
- Object.keys(SOCKET_EVENTS).forEach(key => {
12340
+ Object.keys(SOCKET_EVENTS$1).forEach(key => {
12246
12341
  // $FlowFixMe
12247
- this[key] = SOCKET_EVENTS[key];
12342
+ this[key] = SOCKET_EVENTS$1[key];
12248
12343
  });
12249
12344
  this.eventLists = WebSocketClient.eventLists;
12250
12345
 
@@ -12252,7 +12347,7 @@ class Websocket extends Emitter {
12252
12347
  }
12253
12348
 
12254
12349
  open(host , session ) {
12255
- logger$3.info('open simple WebSocket', { host, token: session.token });
12350
+ logger$9.info('open simple WebSocket', { host, token: session.token });
12256
12351
  this.ws = new WebSocketClient(
12257
12352
  {
12258
12353
  host,
@@ -12280,7 +12375,7 @@ class Websocket extends Emitter {
12280
12375
  }
12281
12376
 
12282
12377
  updateToken(token ) {
12283
- logger$3.info('update token via simple Websocket', { token, ws: !!this.ws });
12378
+ logger$9.info('update token via simple Websocket', { token, ws: !!this.ws });
12284
12379
 
12285
12380
  if (!this.ws) {
12286
12381
  return;
@@ -12308,7 +12403,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
12308
12403
 
12309
12404
  //
12310
12405
 
12311
- const logger$2 = IssueReporter$1.loggerFor('room');
12406
+ const logger$a = IssueReporter$1.loggerFor('room');
12312
12407
 
12313
12408
  class Participant extends Emitter {
12314
12409
 
@@ -12430,7 +12525,7 @@ class Participant extends Emitter {
12430
12525
  }
12431
12526
 
12432
12527
  onTalking(isTalking ) {
12433
- logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12528
+ logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12434
12529
  this.isTalking = isTalking;
12435
12530
  // you may notice we're not broadcasting: since all participants are getting this info
12436
12531
  // directly from asterisk, there's no need to do so
@@ -12533,7 +12628,7 @@ class Participant extends Emitter {
12533
12628
  }
12534
12629
 
12535
12630
  updateStatus(status , broadcast = true) {
12536
- logger$2.info('updating participant status', { name: this.name, status });
12631
+ logger$a.info('updating participant status', { name: this.name, status });
12537
12632
 
12538
12633
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
12539
12634
  if (status.audioMuted) {
@@ -12581,7 +12676,7 @@ class Participant extends Emitter {
12581
12676
 
12582
12677
  broadcastStatus(inboundStatus = null) {
12583
12678
  const status = inboundStatus || this.getStatus();
12584
- logger$2.info('broadcasting participant status', { callId: this.callId, status });
12679
+ logger$a.info('broadcasting participant status', { callId: this.callId, status });
12585
12680
 
12586
12681
  this.room.sendSignal({
12587
12682
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -12617,9 +12712,9 @@ class LocalParticipant extends Participant {
12617
12712
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12618
12713
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12619
12714
 
12620
- const logger$1 = IssueReporter$1.loggerFor('sdk-room');
12715
+ const logger$b = IssueReporter$1.loggerFor('sdk-room');
12621
12716
 
12622
- class Room extends Emitter {
12717
+ class Room$1 extends Emitter {
12623
12718
 
12624
12719
 
12625
12720
 
@@ -12677,7 +12772,7 @@ class Room extends Emitter {
12677
12772
  extra = {},
12678
12773
  ) {
12679
12774
  super();
12680
- logger$1.info('room initialized', { callId, extension, sourceId, meetingUuid });
12775
+ logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
12681
12776
 
12682
12777
  // Represents the room callSession
12683
12778
  this.callSession = callSession;
@@ -12743,7 +12838,7 @@ class Room extends Emitter {
12743
12838
  * @returns {Promise<Room>}
12744
12839
  */
12745
12840
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
12746
- logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
12841
+ logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
12747
12842
 
12748
12843
  if (!room) {
12749
12844
  await Wazo.Phone.connect();
@@ -12756,7 +12851,7 @@ class Room extends Emitter {
12756
12851
 
12757
12852
  // Call_created is triggered before call_accepted, so we have to listen for it here.
12758
12853
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
12759
- logger$1.info('room call received via WS', { callId: data.call_id });
12854
+ logger$b.info('room call received via WS', { callId: data.call_id });
12760
12855
  if (room) {
12761
12856
  room.setCallId(data.call_id);
12762
12857
  }
@@ -12764,7 +12859,7 @@ class Room extends Emitter {
12764
12859
 
12765
12860
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
12766
12861
  // eslint-disable-next-line no-param-reassign
12767
- room = new Room(callSession, extension, null, null, extra);
12862
+ room = new Room$1(callSession, extension, null, null, extra);
12768
12863
 
12769
12864
  // Wait for the call to be accepted
12770
12865
  await new Promise((resolve, reject) => {
@@ -12785,7 +12880,7 @@ class Room extends Emitter {
12785
12880
  // Retrieve conference
12786
12881
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
12787
12882
 
12788
- logger$1.info('connected to room', {
12883
+ logger$b.info('connected to room', {
12789
12884
  sourceId: conference ? conference.sourceId : null,
12790
12885
  name: conference ? conference.name : null,
12791
12886
  });
@@ -12795,7 +12890,7 @@ class Room extends Emitter {
12795
12890
  room.setName(conference.name);
12796
12891
  }
12797
12892
  } else if (meeting) {
12798
- logger$1.info('Already connected to meeting', {
12893
+ logger$b.info('Already connected to meeting', {
12799
12894
  uuid: meeting.uuid,
12800
12895
  name: meeting.name,
12801
12896
  });
@@ -12808,13 +12903,13 @@ class Room extends Emitter {
12808
12903
  }
12809
12904
 
12810
12905
  static disconnect() {
12811
- logger$1.info('static disconnection to room');
12906
+ logger$b.info('static disconnection to room');
12812
12907
 
12813
12908
  Wazo.Phone.disconnect();
12814
12909
  }
12815
12910
 
12816
12911
  async disconnect() {
12817
- logger$1.info('disconnection to room called');
12912
+ logger$b.info('disconnection to room called');
12818
12913
 
12819
12914
  await Wazo.Phone.hangup(this.callSession);
12820
12915
  this.callSession = null;
@@ -12834,19 +12929,19 @@ class Room extends Emitter {
12834
12929
  }
12835
12930
 
12836
12931
  setSourceId(sourceId ) {
12837
- logger$1.info('set room source id', { sourceId });
12932
+ logger$b.info('set room source id', { sourceId });
12838
12933
 
12839
12934
  this.sourceId = sourceId;
12840
12935
  }
12841
12936
 
12842
12937
  setMeetingUuid(meetingUuid ) {
12843
- logger$1.info('set meeting uuid', { meetingUuid });
12938
+ logger$b.info('set meeting uuid', { meetingUuid });
12844
12939
 
12845
12940
  this.meetingUuid = meetingUuid;
12846
12941
  }
12847
12942
 
12848
12943
  setCallId(callId ) {
12849
- logger$1.info('set room call id', { callId });
12944
+ logger$b.info('set room call id', { callId });
12850
12945
 
12851
12946
  if (callId) {
12852
12947
  this.callId = callId;
@@ -12854,7 +12949,7 @@ class Room extends Emitter {
12854
12949
  }
12855
12950
 
12856
12951
  setName(name ) {
12857
- logger$1.info('set room name', { name });
12952
+ logger$b.info('set room name', { name });
12858
12953
 
12859
12954
  this.name = name;
12860
12955
  }
@@ -12873,7 +12968,7 @@ class Room extends Emitter {
12873
12968
  }
12874
12969
 
12875
12970
  async startScreenSharing(constraints ) {
12876
- logger$1.info('start room screen sharing', { constraints });
12971
+ logger$b.info('start room screen sharing', { constraints });
12877
12972
 
12878
12973
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
12879
12974
  if (!screensharingStream) {
@@ -12887,7 +12982,7 @@ class Room extends Emitter {
12887
12982
  }
12888
12983
 
12889
12984
  async stopScreenSharing(restoreLocalStream = true) {
12890
- logger$1.info('stop room screen sharing');
12985
+ logger$b.info('stop room screen sharing');
12891
12986
 
12892
12987
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
12893
12988
 
@@ -12899,7 +12994,7 @@ class Room extends Emitter {
12899
12994
  }
12900
12995
 
12901
12996
  turnCameraOff() {
12902
- logger$1.info('turn room camera off');
12997
+ logger$b.info('turn room camera off');
12903
12998
 
12904
12999
  Wazo.Phone.turnCameraOff(this.callSession);
12905
13000
 
@@ -12909,7 +13004,7 @@ class Room extends Emitter {
12909
13004
  }
12910
13005
 
12911
13006
  turnCameraOn() {
12912
- logger$1.info('turn room camera on');
13007
+ logger$b.info('turn room camera on');
12913
13008
 
12914
13009
  Wazo.Phone.turnCameraOn(this.callSession);
12915
13010
 
@@ -12919,7 +13014,7 @@ class Room extends Emitter {
12919
13014
  }
12920
13015
 
12921
13016
  mute() {
12922
- logger$1.info('mute room');
13017
+ logger$b.info('mute room');
12923
13018
 
12924
13019
  Wazo.Phone.mute(this.callSession);
12925
13020
 
@@ -12927,7 +13022,7 @@ class Room extends Emitter {
12927
13022
  }
12928
13023
 
12929
13024
  unmute() {
12930
- logger$1.info('unmute room');
13025
+ logger$b.info('unmute room');
12931
13026
 
12932
13027
  Wazo.Phone.unmute(this.callSession);
12933
13028
 
@@ -12947,7 +13042,7 @@ class Room extends Emitter {
12947
13042
  }
12948
13043
 
12949
13044
  hold() {
12950
- logger$1.info('hold room');
13045
+ logger$b.info('hold room');
12951
13046
 
12952
13047
  Wazo.Phone.hold(this.callSession, true);
12953
13048
 
@@ -12957,7 +13052,7 @@ class Room extends Emitter {
12957
13052
  }
12958
13053
 
12959
13054
  async resume() {
12960
- logger$1.info('resume room');
13055
+ logger$b.info('resume room');
12961
13056
 
12962
13057
  const newStream = await Wazo.Phone.resume(this.callSession, true);
12963
13058
 
@@ -12985,13 +13080,13 @@ class Room extends Emitter {
12985
13080
  }
12986
13081
 
12987
13082
  sendDTMF(tone ) {
12988
- logger$1.info('send room DTMF', { tone });
13083
+ logger$b.info('send room DTMF', { tone });
12989
13084
 
12990
13085
  Wazo.Phone.sendDTMF(tone, this.callSession);
12991
13086
  }
12992
13087
 
12993
13088
  async sendReinvite(newConstraints = null) {
12994
- logger$1.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13089
+ logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
12995
13090
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
12996
13091
 
12997
13092
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13050,7 +13145,7 @@ class Room extends Emitter {
13050
13145
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13051
13146
 
13052
13147
  this.on(this.ON_AUDIO_STREAM, stream => {
13053
- logger$1.info('on room audio stream');
13148
+ logger$b.info('on room audio stream');
13054
13149
 
13055
13150
  this.audioStream = stream;
13056
13151
  if (!this.roomAudioElement) {
@@ -13063,7 +13158,7 @@ class Room extends Emitter {
13063
13158
  });
13064
13159
 
13065
13160
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13066
- logger$1.info('on room video stream', { streamId });
13161
+ logger$b.info('on room video stream', { streamId });
13067
13162
 
13068
13163
  this._mapMsid(sipSession.body.body);
13069
13164
 
@@ -13078,7 +13173,7 @@ class Room extends Emitter {
13078
13173
  });
13079
13174
 
13080
13175
  this.on(this.ON_REMOVE_STREAM, stream => {
13081
- logger$1.info('on room remove stream');
13176
+ logger$b.info('on room remove stream');
13082
13177
 
13083
13178
  const participant = this.participants.find(someParticipant =>
13084
13179
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13210,7 +13305,7 @@ class Room extends Emitter {
13210
13305
  const requester = this._getParticipantFromCallId(origin.callId);
13211
13306
  if (requester) {
13212
13307
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13213
- logger$1.info('trigger room requester status', { origin });
13308
+ logger$b.info('trigger room requester status', { origin });
13214
13309
  requester.triggerUpdate('REQUESTER_UPDATE');
13215
13310
  }
13216
13311
  break;
@@ -13241,24 +13336,24 @@ class Room extends Emitter {
13241
13336
 
13242
13337
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13243
13338
  if (participant.user_uuid === session.uuid) {
13244
- logger$1.info('room current user joined');
13339
+ logger$b.info('room current user joined');
13245
13340
 
13246
13341
  // Retrieve participants via an API calls
13247
13342
  const conferenceId = this.sourceId || payload.data.conference_id;
13248
13343
  let response;
13249
13344
  try {
13250
13345
  if (this.meetingUuid) {
13251
- logger$1.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13346
+ logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13252
13347
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13253
13348
  } else {
13254
- logger$1.info('fetching conference participants', { conferenceId });
13349
+ logger$b.info('fetching conference participants', { conferenceId });
13255
13350
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13256
13351
  }
13257
13352
  } catch (e) {
13258
- logger$1.error('room participants fetching, error', e);
13353
+ logger$b.error('room participants fetching, error', e);
13259
13354
  }
13260
13355
  if (response) {
13261
- logger$1.info('conference participants fetched', { nb: response.items.length });
13356
+ logger$b.info('conference participants fetched', { nb: response.items.length });
13262
13357
  participants = response.items.map(item => {
13263
13358
  const isMe = item.call_id === this.callId;
13264
13359
 
@@ -13285,7 +13380,7 @@ class Room extends Emitter {
13285
13380
  ? new Wazo.RemoteParticipant(this, participant)
13286
13381
  : null;
13287
13382
 
13288
- logger$1.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13383
+ logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13289
13384
 
13290
13385
  if (remoteParticipant) {
13291
13386
  this.participants.push(remoteParticipant);
@@ -13450,12 +13545,12 @@ class Room extends Emitter {
13450
13545
 
13451
13546
  //
13452
13547
 
13453
- const logger = IssueReporter$1.loggerFor('sdk-sip-room');
13548
+ const logger$c = IssueReporter$1.loggerFor('sdk-sip-room');
13454
13549
 
13455
- class SipRoom extends Room {
13550
+ class SipRoom extends Room$1 {
13456
13551
 
13457
13552
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
13458
- logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
13553
+ logger$c.info('connecting to sip room', { extension, audioOnly, room: !!room });
13459
13554
 
13460
13555
  if (!room) {
13461
13556
  await Wazo.Phone.connect();
@@ -13471,7 +13566,7 @@ class SipRoom extends Room {
13471
13566
  room.setCallId(room.callSession.call.id);
13472
13567
  }
13473
13568
 
13474
- logger.info('connected to room', {
13569
+ logger$c.info('connected to room', {
13475
13570
  extension: room.extension,
13476
13571
  });
13477
13572
 
@@ -13479,7 +13574,7 @@ class SipRoom extends Room {
13479
13574
  }
13480
13575
 
13481
13576
  mute() {
13482
- logger.info('mute sip room');
13577
+ logger$c.info('mute sip room');
13483
13578
 
13484
13579
  Wazo.Phone.mute(this.callSession, false);
13485
13580
 
@@ -13487,7 +13582,7 @@ class SipRoom extends Room {
13487
13582
  }
13488
13583
 
13489
13584
  unmute() {
13490
- logger.info('unmute sip room');
13585
+ logger$c.info('unmute sip room');
13491
13586
 
13492
13587
  Wazo.Phone.unmute(this.callSession, false);
13493
13588
 
@@ -13700,7 +13795,7 @@ const Wazo = {
13700
13795
  Auth: Auth$1,
13701
13796
  Phone: Phone$1,
13702
13797
  Websocket: Websocket$1,
13703
- Room,
13798
+ Room: Room$1,
13704
13799
  SipRoom,
13705
13800
  RemoteParticipant,
13706
13801
  LocalParticipant,
@@ -13733,7 +13828,7 @@ const Wazo = {
13733
13828
  Session,
13734
13829
  Voicemail,
13735
13830
  Relocation,
13736
- ConferenceRoom: Room$1,
13831
+ ConferenceRoom: Room,
13737
13832
  CallSession,
13738
13833
  IndirectTransfer,
13739
13834
  SwitchboardCall,
@@ -13819,13 +13914,13 @@ var index = {
13819
13914
  Session,
13820
13915
  Voicemail,
13821
13916
  Relocation,
13822
- Room: Room$1,
13917
+ Room,
13823
13918
  IssueReporter: IssueReporter$1,
13824
13919
  DebugDevice,
13825
13920
  PROFILE_STATE: STATE,
13826
13921
  FORWARD_KEYS,
13827
13922
  LINE_STATE,
13828
- SOCKET_EVENTS: SOCKET_EVENTS$1,
13923
+ SOCKET_EVENTS,
13829
13924
  Wazo,
13830
13925
  WebRTCPhone,
13831
13926
  Meeting,