@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
@@ -159,6 +159,7 @@ class IssueReporter {
159
159
 
160
160
 
161
161
 
162
+
162
163
 
163
164
  constructor() {
164
165
  addLevelsTo(this);
@@ -170,12 +171,17 @@ class IssueReporter {
170
171
  this.bufferTimeout = null;
171
172
  this._boundProcessBuffer = this._processBuffer.bind(this);
172
173
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
174
+ this._callback = null;
173
175
  }
174
176
 
175
177
  init() {
176
178
  this._catchConsole();
177
179
  }
178
180
 
181
+ setCallback(cb ) {
182
+ this._callback = cb;
183
+ }
184
+
179
185
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
180
186
  this.remoteClientConfiguration = configuration;
181
187
  }
@@ -211,6 +217,7 @@ class IssueReporter {
211
217
 
212
218
  // Handle category label
213
219
  let category = null;
220
+ let skipSendToRemote = false;
214
221
  let extra = {};
215
222
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
216
223
  category = args[0].split('=')[1];
@@ -226,6 +233,7 @@ class IssueReporter {
226
233
  errorMessage: lastArg.message,
227
234
  errorStack: lastArg.stack,
228
235
  errorType: lastArg.constructor.name,
236
+ skipSendToRemote: lastArg.skipSendToRemote,
229
237
  };
230
238
  } else {
231
239
  extra = lastArg;
@@ -234,6 +242,11 @@ class IssueReporter {
234
242
  args.splice(1, 1);
235
243
  }
236
244
 
245
+ if (extra.skipSendToRemote) {
246
+ skipSendToRemote = true;
247
+ delete extra.skipSendToRemote;
248
+ }
249
+
237
250
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
238
251
  const message = args.join(', ');
239
252
  let consoleMessage = message;
@@ -254,7 +267,13 @@ class IssueReporter {
254
267
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
255
268
  oldMethod.apply(oldMethod, [date, consoleMessage]);
256
269
 
257
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
270
+ if (this._callback) {
271
+ this._callback(level, consoleMessage);
272
+ }
273
+
274
+ if (!skipSendToRemote) {
275
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
276
+ }
258
277
  }
259
278
 
260
279
  logRequest(url , options , response , start ) {
@@ -399,7 +418,11 @@ class IssueReporter {
399
418
  },
400
419
  // $FlowFixMe
401
420
  body,
402
- }).catch(() => {
421
+ }).catch((e ) => {
422
+ // $FlowFixMe
423
+ e.skipSendToRemote = true;
424
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
425
+
403
426
  setTimeout(() => {
404
427
  if (isArray) {
405
428
  payload = payload.map(message => {
@@ -446,7 +469,7 @@ var IssueReporter$1 = new IssueReporter();
446
469
 
447
470
  const methods = ['head', 'get', 'post', 'put', 'delete'];
448
471
 
449
- const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
472
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
450
473
 
451
474
  // Use a function here to be able to mock it in tests
452
475
  const realFetch = () => {
@@ -585,7 +608,7 @@ class ApiRequester {
585
608
  };
586
609
 
587
610
  if (this.refreshTokenPromise) {
588
- logger$c.info('A token is already refreshing, waiting ...', { url });
611
+ logger.info('A token is already refreshing, waiting ...', { url });
589
612
  await this.refreshTokenPromise;
590
613
  }
591
614
 
@@ -605,7 +628,7 @@ class ApiRequester {
605
628
  return promise.then(async (err ) => {
606
629
  // Check if the token is still valid
607
630
  if (firstCall && this._checkTokenExpired(response, err)) {
608
- logger$c.warn('token expired', { error: err.reason });
631
+ logger.warn('token expired', { error: err.reason });
609
632
  // Replay the call after refreshing the token
610
633
  return this._replayWithNewToken(err, path, method, body, headers, parse);
611
634
  }
@@ -615,7 +638,7 @@ class ApiRequester {
615
638
  : exceptionClass.fromResponse(err, response.status);
616
639
 
617
640
  if (this.shouldLogErrors) {
618
- logger$c.error('API error', error);
641
+ logger.error('API error', error);
619
642
  }
620
643
 
621
644
  throw error;
@@ -625,7 +648,7 @@ class ApiRequester {
625
648
  return newParse(response, isJson);
626
649
  }).catch(error => {
627
650
  if (this.shouldLogErrors) {
628
- logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
651
+ logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
629
652
  }
630
653
 
631
654
  throw error;
@@ -653,13 +676,13 @@ class ApiRequester {
653
676
  ) {
654
677
  const isTokenNotFound = this._isTokenNotFound(err);
655
678
  let newPath = path;
656
- logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
679
+ logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
657
680
 
658
681
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
659
682
 
660
683
  return this.refreshTokenPromise.then(() => {
661
684
  this.refreshTokenPromise = null;
662
- logger$c.info('token refreshed', { isTokenNotFound });
685
+ logger.info('token refreshed', { isTokenNotFound });
663
686
  if (isTokenNotFound) {
664
687
  const pathParts = path.split('/');
665
688
  pathParts.pop();
@@ -1537,6 +1560,9 @@ class Contact {
1537
1560
  }
1538
1561
 
1539
1562
  static parseMany(response ) {
1563
+ if (!response || !response.results) {
1564
+ return [];
1565
+ }
1540
1566
  return response.results.map(r => Contact.parse(r, response.column_types));
1541
1567
  }
1542
1568
 
@@ -2614,8 +2640,9 @@ class ExternalApp {
2614
2640
 
2615
2641
 
2616
2642
 
2617
-
2643
+
2618
2644
 
2645
+
2619
2646
 
2620
2647
 
2621
2648
  class Meeting {
@@ -2626,9 +2653,10 @@ class Meeting {
2626
2653
 
2627
2654
 
2628
2655
 
2629
-
2656
+
2630
2657
 
2631
2658
 
2659
+
2632
2660
 
2633
2661
  static parse(plain ) {
2634
2662
  return new Meeting({
@@ -2638,24 +2666,43 @@ class Meeting {
2638
2666
  ownerUuids: plain.owner_uuids,
2639
2667
  port: plain.port,
2640
2668
  uuid: plain.uuid,
2641
- number: plain.number,
2669
+ extension: plain.exten,
2642
2670
  persistent: plain.persistent,
2671
+ creationTime: moment__default['default'](plain.creation_time).toDate(),
2643
2672
  });
2644
2673
  }
2645
2674
 
2675
+ static parseMany(items ) {
2676
+ if (!items) {
2677
+ return [];
2678
+ }
2679
+ return items.map(plain => Meeting.parse(plain));
2680
+ }
2681
+
2646
2682
  static newFrom(meeting ) {
2647
2683
  return newFrom(meeting, Meeting);
2648
2684
  }
2649
2685
 
2650
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2686
+ constructor({
2687
+ uuid,
2688
+ name,
2689
+ guestSipAuthorization,
2690
+ ownerUuids,
2691
+ port,
2692
+ uri,
2693
+ extension,
2694
+ persistent,
2695
+ creationTime,
2696
+ } = {}) {
2651
2697
  this.guestSipAuthorization = guestSipAuthorization;
2652
2698
  this.uri = uri;
2653
2699
  this.name = name;
2654
2700
  this.ownerUuids = ownerUuids;
2655
2701
  this.port = port;
2656
2702
  this.uuid = uuid;
2657
- this.number = number;
2703
+ this.extension = extension;
2658
2704
  this.persistent = persistent;
2705
+ this.creationTime = creationTime;
2659
2706
 
2660
2707
  // Useful to compare instead of instanceof with minified code
2661
2708
  this.type = 'Meeting';
@@ -2733,8 +2780,11 @@ var confdMethods = (client , baseUrl ) => ({
2733
2780
  }
2734
2781
  },
2735
2782
 
2736
- createMyMeeting: (name ) =>
2737
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2783
+ getMyMeetings: () =>
2784
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2785
+
2786
+ createMyMeeting: (name , persistent ) =>
2787
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2738
2788
 
2739
2789
  deleteMyMeeting: (meetingUuid ) =>
2740
2790
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2830,6 +2880,10 @@ class ChatMessage {
2830
2880
 
2831
2881
 
2832
2882
  static parseMany(plain ) {
2883
+ if (!plain || !plain.items) {
2884
+ return [];
2885
+ }
2886
+
2833
2887
  return plain.items.map(item => ChatMessage.parse(item));
2834
2888
  }
2835
2889
 
@@ -2939,6 +2993,9 @@ class Voicemail {
2939
2993
  }
2940
2994
 
2941
2995
  static parseMany(plain ) {
2996
+ if (!plain) {
2997
+ return [];
2998
+ }
2942
2999
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2943
3000
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2944
3001
 
@@ -3048,6 +3105,9 @@ class Call {
3048
3105
 
3049
3106
 
3050
3107
  static parseMany(plain ) {
3108
+ if (!plain) {
3109
+ return [];
3110
+ }
3051
3111
  return plain.map((plainCall ) => Call.parse(plainCall));
3052
3112
  }
3053
3113
 
@@ -3591,6 +3651,9 @@ class Recording {
3591
3651
 
3592
3652
 
3593
3653
  static parseMany(recordings = []) {
3654
+ if (!recordings) {
3655
+ return [];
3656
+ }
3594
3657
  return recordings.map(item => Recording.parse(item));
3595
3658
  }
3596
3659
 
@@ -3692,6 +3755,10 @@ class CallLog {
3692
3755
  }
3693
3756
 
3694
3757
  static parseMany(plain ) {
3758
+ if (!plain || !plain.items) {
3759
+ return [];
3760
+ }
3761
+
3695
3762
  return plain.items.map(item => CallLog.parse(item));
3696
3763
  }
3697
3764
 
@@ -3996,7 +4063,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
3996
4063
 
3997
4064
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
3998
4065
 
3999
- const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4066
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4000
4067
 
4001
4068
  class CTIPhone extends Emitter {
4002
4069
 
@@ -4009,7 +4076,7 @@ class CTIPhone extends Emitter {
4009
4076
 
4010
4077
  constructor(session , isMobile = false, callbackAllLines = false) {
4011
4078
  super();
4012
- logger$b.info('CTI Phone created');
4079
+ logger$1.info('CTI Phone created');
4013
4080
  this.session = session;
4014
4081
  this.isMobile = isMobile;
4015
4082
  this.callbackAllLines = callbackAllLines;
@@ -4070,7 +4137,7 @@ class CTIPhone extends Emitter {
4070
4137
  }
4071
4138
 
4072
4139
  async makeCall(number , line ) {
4073
- logger$b.info('make CTI call', { number });
4140
+ logger$1.info('make CTI call', { number });
4074
4141
 
4075
4142
  if (!number) {
4076
4143
  return null;
@@ -4093,7 +4160,7 @@ class CTIPhone extends Emitter {
4093
4160
  if (!callSession) {
4094
4161
  return Promise.resolve(null);
4095
4162
  }
4096
- logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4163
+ logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4097
4164
 
4098
4165
  if (!this.currentCall) {
4099
4166
  this.currentCall = callSession.call;
@@ -4106,7 +4173,7 @@ class CTIPhone extends Emitter {
4106
4173
  if (!callSession) {
4107
4174
  return;
4108
4175
  }
4109
- logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4176
+ logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4110
4177
 
4111
4178
  this.currentCall = undefined;
4112
4179
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4116,7 +4183,7 @@ class CTIPhone extends Emitter {
4116
4183
  if (!callSession) {
4117
4184
  return Promise.resolve(false);
4118
4185
  }
4119
- logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4186
+ logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4120
4187
 
4121
4188
  try {
4122
4189
  await CallApi.cancelCall(callSession);
@@ -4127,7 +4194,7 @@ class CTIPhone extends Emitter {
4127
4194
  this.eventEmitter.emit('onCallEnded', callSession);
4128
4195
  return true;
4129
4196
  } catch (e) {
4130
- logger$b.error('hangup CTI call, error', e);
4197
+ logger$1.error('hangup CTI call, error', e);
4131
4198
 
4132
4199
  this.eventEmitter.emit('onCallFailed', callSession);
4133
4200
  return false;
@@ -4140,7 +4207,7 @@ class CTIPhone extends Emitter {
4140
4207
  if (!callSession) {
4141
4208
  return;
4142
4209
  }
4143
- logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4210
+ logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4144
4211
 
4145
4212
  await CallApi.cancelCall(callSession);
4146
4213
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4150,7 +4217,7 @@ class CTIPhone extends Emitter {
4150
4217
  if (!callSession) {
4151
4218
  return;
4152
4219
  }
4153
- logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4220
+ logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4154
4221
 
4155
4222
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4156
4223
  }
@@ -4163,19 +4230,19 @@ class CTIPhone extends Emitter {
4163
4230
  if (!callSession) {
4164
4231
  return;
4165
4232
  }
4166
- logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4233
+ logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4167
4234
 
4168
4235
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4169
4236
  }
4170
4237
 
4171
4238
  async cancelCTIIndirectTransfer(transferId ) {
4172
- logger$b.info('cancel CTI transfer', { transferId });
4239
+ logger$1.info('cancel CTI transfer', { transferId });
4173
4240
 
4174
4241
  return CallApi.cancelCallTransfer(transferId);
4175
4242
  }
4176
4243
 
4177
4244
  async confirmCTIIndirectTransfer(transferId ) {
4178
- logger$b.info('confirm CTI transfer', { transferId });
4245
+ logger$1.info('confirm CTI transfer', { transferId });
4179
4246
 
4180
4247
  return CallApi.confirmCallTransfer(transferId);
4181
4248
  }
@@ -4184,19 +4251,19 @@ class CTIPhone extends Emitter {
4184
4251
  if (!callSession) {
4185
4252
  return;
4186
4253
  }
4187
- logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4254
+ logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4188
4255
 
4189
4256
  return CallApi.sendDTMF(callSession.callId, digits);
4190
4257
  }
4191
4258
 
4192
4259
  onConnectionMade() {
4193
- logger$b.info('on CTI connection made');
4260
+ logger$1.info('on CTI connection made');
4194
4261
 
4195
4262
  this.eventEmitter.emit('onCallAccepted');
4196
4263
  }
4197
4264
 
4198
4265
  async close() {
4199
- logger$b.info('CTI close');
4266
+ logger$1.info('CTI close');
4200
4267
 
4201
4268
  return Promise.resolve();
4202
4269
  }
@@ -4205,7 +4272,7 @@ class CTIPhone extends Emitter {
4205
4272
  if (!callSession) {
4206
4273
  return;
4207
4274
  }
4208
- logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4275
+ logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4209
4276
 
4210
4277
  return CallApi.hold(callSession.callId);
4211
4278
  }
@@ -4214,7 +4281,7 @@ class CTIPhone extends Emitter {
4214
4281
  if (!callSession) {
4215
4282
  return;
4216
4283
  }
4217
- logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4284
+ logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4218
4285
 
4219
4286
  return CallApi.resume(callSession.callId);
4220
4287
  }
@@ -4223,7 +4290,7 @@ class CTIPhone extends Emitter {
4223
4290
  if (!callSession) {
4224
4291
  return;
4225
4292
  }
4226
- logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4293
+ logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4227
4294
 
4228
4295
  return CallApi.mute(callSession.callId);
4229
4296
  }
@@ -4232,7 +4299,7 @@ class CTIPhone extends Emitter {
4232
4299
  if (!callSession) {
4233
4300
  return;
4234
4301
  }
4235
- logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4302
+ logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4236
4303
 
4237
4304
  return CallApi.unmute(callSession.callId);
4238
4305
  }
@@ -4261,6 +4328,10 @@ class CTIPhone extends Emitter {
4261
4328
  return false;
4262
4329
  }
4263
4330
 
4331
+ hasAVideoTrack() {
4332
+ return false;
4333
+ }
4334
+
4264
4335
  getLocalStreamForCall() {
4265
4336
  return null;
4266
4337
  }
@@ -4654,6 +4725,9 @@ class ChatRoom {
4654
4725
 
4655
4726
 
4656
4727
  static parseMany(plain ) {
4728
+ if (!plain || !plain.items) {
4729
+ return [];
4730
+ }
4657
4731
  return plain.items.map(item => ChatRoom.parse(item));
4658
4732
  }
4659
4733
 
@@ -5234,7 +5308,7 @@ const AGENTD_VERSION = '1.0';
5234
5308
  const WEBHOOKD_VERSION = '1.0';
5235
5309
  const AMID_VERSION = '1.0';
5236
5310
 
5237
- const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5311
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5238
5312
 
5239
5313
  class ApiClient {
5240
5314
 
@@ -5286,12 +5360,12 @@ class ApiClient {
5286
5360
  }
5287
5361
 
5288
5362
  async forceRefreshToken() {
5289
- logger$a.info('forcing refresh token, calling callback');
5363
+ logger$2.info('forcing refresh token, calling callback');
5290
5364
  return this.refreshTokenCallback();
5291
5365
  }
5292
5366
 
5293
5367
  async refreshTokenCallback() {
5294
- logger$a.info('refresh token callback called', {
5368
+ logger$2.info('refresh token callback called', {
5295
5369
  refreshToken: this.refreshToken,
5296
5370
  refreshBackend: this.refreshBackend,
5297
5371
  refreshExpiration: this.refreshExpiration,
@@ -5309,7 +5383,7 @@ class ApiClient {
5309
5383
  this.isMobile,
5310
5384
  );
5311
5385
 
5312
- logger$a.info('token refreshed', { token: session.token });
5386
+ logger$2.info('token refreshed', { token: session.token });
5313
5387
 
5314
5388
  if (this.onRefreshToken) {
5315
5389
  this.onRefreshToken(session.token, session);
@@ -5450,7 +5524,7 @@ var getApiClient = (forServer ) => {
5450
5524
  class InvalidSubscription extends Error {}
5451
5525
  class InvalidAuthorization extends Error {}
5452
5526
 
5453
- const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5527
+ const logger$3 = IssueReporter$1.loggerFor('simple-auth');
5454
5528
 
5455
5529
  class Auth {
5456
5530
 
@@ -5485,7 +5559,7 @@ class Auth {
5485
5559
  setApiClientId(this.clientId);
5486
5560
  setRefreshExpiration(this.expiration);
5487
5561
  setOnRefreshToken((token , session ) => {
5488
- logger$9.info('on refresh token done', { token });
5562
+ logger$3.info('on refresh token done', { token });
5489
5563
  setApiToken(token);
5490
5564
  Wazo.Websocket.updateToken(token);
5491
5565
 
@@ -5530,7 +5604,7 @@ class Auth {
5530
5604
  const rawSession = await getApiClient().auth.authenticate(token);
5531
5605
  return this._onAuthenticated(rawSession);
5532
5606
  } catch (e) {
5533
- logger$9.error('on validate token error', e);
5607
+ logger$3.error('on validate token error', e);
5534
5608
  console.warn(e);
5535
5609
  return false;
5536
5610
  }
@@ -5886,7 +5960,7 @@ class AdHocAPIConference {
5886
5960
 
5887
5961
  /* */
5888
5962
 
5889
- const parseCandidate$1 = (candidate ) => {
5963
+ const parseCandidate = (candidate ) => {
5890
5964
  if (!candidate) {
5891
5965
  return null;
5892
5966
  }
@@ -5899,10 +5973,6 @@ const getSrflxOrRelay = (candidates ) =>
5899
5973
  candidates
5900
5974
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5901
5975
 
5902
- const areCandidateValid = (candidates ) =>
5903
- getSrflxOrRelay(candidates)
5904
- .length > 0;
5905
-
5906
5976
  const getVideoDirection = (sdp ) => {
5907
5977
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5908
5978
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5955,8 +6025,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5955
6025
  /* global RTCSessionDescriptionInit, navigator */
5956
6026
 
5957
6027
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5958
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5959
- const WAIT_FOR_ICE_TIMEOUT = 500;
5960
6028
 
5961
6029
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5962
6030
  const wazoMediaStreamFactory = (constraints ) => {
@@ -6046,7 +6114,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6046
6114
  this.peerConnectionDelegate.onicecandidate = event => {
6047
6115
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6048
6116
  if (event.candidate) {
6049
- this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6117
+ this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
6050
6118
  }
6051
6119
  };
6052
6120
 
@@ -6146,38 +6214,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6146
6214
  this._peerConnection = undefined;
6147
6215
  }
6148
6216
 
6149
- async _waitForValidGatheredIce() {
6150
- let tries = 0;
6151
-
6152
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
6153
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
6154
- tries,
6155
- max: MAX_WAIT_FOR_ICE_TRIES,
6156
- });
6157
-
6158
- tries++;
6159
-
6160
- // eslint-disable-next-line no-await-in-loop
6161
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
6162
- }
6163
-
6164
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
6165
- const errorMsg = 'No valid candidates found, can\'t answer the call';
6166
- const error = new Error(errorMsg);
6167
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
6168
-
6169
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
6170
- this.eventEmitter.emit('error', error);
6171
-
6172
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6173
- }
6174
-
6175
- // eslint-disable-next-line
6176
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6177
-
6178
- return this.getLocalSessionDescription();
6179
- }
6180
-
6181
6217
  // Overridden to send `inactive` in conference
6182
6218
  updateDirection(options , isConference = false,
6183
6219
  audioOnly = false) {
@@ -6542,7 +6578,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6542
6578
  const SEND_STATS_DELAY = 5000;
6543
6579
 
6544
6580
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6545
- const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6581
+ const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6546
6582
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6547
6583
 
6548
6584
  // events
@@ -6556,14 +6592,14 @@ const TRANSPORT_ERROR = 'transportError';
6556
6592
  const MESSAGE = 'message';
6557
6593
  const ACCEPTED = 'accepted';
6558
6594
  const REJECTED = 'rejected';
6559
- const ON_TRACK$1 = 'onTrack';
6560
- const ON_REINVITE$1 = 'reinvite';
6595
+ const ON_TRACK = 'onTrack';
6596
+ const ON_REINVITE = 'reinvite';
6561
6597
  const ON_ERROR = 'onError';
6562
6598
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6563
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
6564
- const ON_DISCONNECTED$1 = 'onDisconnected';
6599
+ const ON_NETWORK_STATS = 'onNetworkStats';
6600
+ const ON_DISCONNECTED = 'onDisconnected';
6565
6601
 
6566
- const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6602
+ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6567
6603
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6568
6604
  class CanceledCallError extends Error {}
6569
6605
 
@@ -6699,12 +6735,12 @@ class WebRTCClient extends Emitter {
6699
6735
  this.MESSAGE = MESSAGE;
6700
6736
  this.ACCEPTED = ACCEPTED;
6701
6737
  this.REJECTED = REJECTED;
6702
- this.ON_TRACK = ON_TRACK$1;
6703
- this.ON_REINVITE = ON_REINVITE$1;
6738
+ this.ON_TRACK = ON_TRACK;
6739
+ this.ON_REINVITE = ON_REINVITE;
6704
6740
  this.ON_ERROR = ON_ERROR;
6705
6741
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6706
- this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6707
- this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6742
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6743
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
6708
6744
  }
6709
6745
 
6710
6746
  configureMedia(media ) {
@@ -6721,13 +6757,13 @@ class WebRTCClient extends Emitter {
6721
6757
 
6722
6758
  createUserAgent(configOverrides ) {
6723
6759
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6724
- logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6760
+ logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
6725
6761
 
6726
6762
  webRTCConfiguration.delegate = {
6727
6763
  onConnect: this.onConnect.bind(this),
6728
6764
  onDisconnect: this.onDisconnect.bind(this),
6729
6765
  onInvite: (invitation ) => {
6730
- logger$8.info('sdk webrtc on invite', {
6766
+ logger$4.info('sdk webrtc on invite', {
6731
6767
  method: 'delegate.onInvite',
6732
6768
  id: invitation.id,
6733
6769
  remoteURI: invitation.remoteURI,
@@ -6770,7 +6806,7 @@ class WebRTCClient extends Emitter {
6770
6806
  }
6771
6807
 
6772
6808
  onConnect() {
6773
- logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6809
+ logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6774
6810
  this.eventEmitter.emit(CONNECTED);
6775
6811
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6776
6812
  this.registerer.waitingToggle(false);
@@ -6779,7 +6815,7 @@ class WebRTCClient extends Emitter {
6779
6815
  }
6780
6816
 
6781
6817
  async onDisconnect(error ) {
6782
- logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6818
+ logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6783
6819
  this.connectionPromise = null;
6784
6820
  // The UA will attempt to reconnect automatically when an error occurred
6785
6821
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6804,37 +6840,37 @@ class WebRTCClient extends Emitter {
6804
6840
  };
6805
6841
 
6806
6842
  if (this.skipRegister) {
6807
- logger$8.info('sdk webrtc skip register...', logInfo);
6843
+ logger$4.info('sdk webrtc skip register...', logInfo);
6808
6844
  return Promise.resolve();
6809
6845
  }
6810
6846
 
6811
- logger$8.info('sdk webrtc registering...', logInfo);
6847
+ logger$4.info('sdk webrtc registering...', logInfo);
6812
6848
 
6813
6849
  if (!this.userAgent) {
6814
- logger$8.info('sdk webrtc recreating User Agent');
6850
+ logger$4.info('sdk webrtc recreating User Agent');
6815
6851
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6816
6852
  }
6817
6853
  if (!this.userAgent || this.isRegistered()) {
6818
- logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6854
+ logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
6819
6855
  return Promise.resolve();
6820
6856
  }
6821
6857
 
6822
6858
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6823
- logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6859
+ logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
6824
6860
  return Promise.resolve();
6825
6861
  }
6826
6862
 
6827
6863
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6828
6864
 
6829
6865
  const onRegisterFailed = () => {
6830
- logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6866
+ logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6831
6867
  this.connectionPromise = null;
6832
6868
  if (this.registerer && this.registerer.waiting) {
6833
6869
  this.registerer.waitingToggle(false);
6834
6870
  }
6835
6871
 
6836
6872
  if (tries <= MAX_REGISTER_TRIES) {
6837
- logger$8.info('sdk webrtc registering, retrying...', { tries });
6873
+ logger$4.info('sdk webrtc registering, retrying...', { tries });
6838
6874
  setTimeout(() => this.register(tries + 1), 300);
6839
6875
  }
6840
6876
  };
@@ -6843,18 +6879,18 @@ class WebRTCClient extends Emitter {
6843
6879
  // Avoid race condition with the close method called just before register and setting userAgent to null
6844
6880
  // during the resolution of the primise.
6845
6881
  if (!this.userAgent) {
6846
- logger$8.info('sdk webrtc recreating User Agent after connection');
6882
+ logger$4.info('sdk webrtc recreating User Agent after connection');
6847
6883
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6848
6884
  }
6849
6885
 
6850
- logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6886
+ logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6851
6887
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6852
6888
  this.connectionPromise = null;
6853
6889
  this._monkeyPatchRegisterer(this.registerer);
6854
6890
 
6855
6891
  // Bind registerer events
6856
6892
  this.registerer.stateChange.addListener(newState => {
6857
- logger$8.info('sdk webrtc registering, state changed', { newState });
6893
+ logger$4.info('sdk webrtc registering, state changed', { newState });
6858
6894
 
6859
6895
  if (newState === registererState.RegistererState.Registered && this.registerer
6860
6896
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6867,7 +6903,7 @@ class WebRTCClient extends Emitter {
6867
6903
  const options = {
6868
6904
  requestDelegate: {
6869
6905
  onReject: response => {
6870
- logger$8.error('sdk webrtc registering, rejected', { response });
6906
+ logger$4.error('sdk webrtc registering, rejected', { response });
6871
6907
 
6872
6908
  onRegisterFailed();
6873
6909
  },
@@ -6875,13 +6911,13 @@ class WebRTCClient extends Emitter {
6875
6911
  };
6876
6912
 
6877
6913
  return this.registerer.register(options).catch((e) => {
6878
- logger$8.error('sdk webrtc registering, error', e);
6914
+ logger$4.error('sdk webrtc registering, error', e);
6879
6915
 
6880
6916
  this.eventEmitter.emit(REGISTRATION_FAILED);
6881
6917
  return e;
6882
6918
  });
6883
6919
  }).catch(error => {
6884
- logger$8.error('sdk webrtc registering, transport error', error);
6920
+ logger$4.error('sdk webrtc registering, transport error', error);
6885
6921
  onRegisterFailed();
6886
6922
  });
6887
6923
  }
@@ -6910,21 +6946,21 @@ class WebRTCClient extends Emitter {
6910
6946
  }
6911
6947
 
6912
6948
  unregister() {
6913
- logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6949
+ logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6914
6950
  if (!this.registerer) {
6915
6951
  return Promise.resolve();
6916
6952
  }
6917
6953
 
6918
6954
  try {
6919
6955
  return this.registerer.unregister().then(() => {
6920
- logger$8.info('sdk webrtc unregistered');
6956
+ logger$4.info('sdk webrtc unregistered');
6921
6957
  this._cleanupRegister();
6922
6958
  }).catch(e => {
6923
- logger$8.error('sdk webrtc unregistering, promise error', e);
6959
+ logger$4.error('sdk webrtc unregistering, promise error', e);
6924
6960
  this._cleanupRegister();
6925
6961
  });
6926
6962
  } catch (e) {
6927
- logger$8.error('sdk webrtc unregistering, error', e);
6963
+ logger$4.error('sdk webrtc unregistering, error', e);
6928
6964
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6929
6965
  // error when the registerer is in a bad state
6930
6966
  this._cleanupRegister();
@@ -6932,7 +6968,7 @@ class WebRTCClient extends Emitter {
6932
6968
  }
6933
6969
 
6934
6970
  stop() {
6935
- logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6971
+ logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6936
6972
  if (!this.userAgent) {
6937
6973
  return Promise.resolve();
6938
6974
  }
@@ -6940,12 +6976,12 @@ class WebRTCClient extends Emitter {
6940
6976
  return this.userAgent.stop().then(() => {
6941
6977
  return this._cleanupRegister();
6942
6978
  }).catch(e => {
6943
- logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6979
+ logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6944
6980
  });
6945
6981
  }
6946
6982
 
6947
6983
  call(number , enableVideo , audioOnly = false, conference = false) {
6948
- logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6984
+ logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6949
6985
  const inviterOptions = {
6950
6986
  sessionDescriptionHandlerOptionsReInvite: {
6951
6987
  conference,
@@ -6970,11 +7006,13 @@ class WebRTCClient extends Emitter {
6970
7006
  const inviteOptions = {
6971
7007
  requestDelegate: {
6972
7008
  onAccept: (response ) => {
6973
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7009
+ if (session.sessionDescriptionHandler.peerConnection) {
7010
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7011
+ }
6974
7012
  this._onAccepted(session, response.session, true);
6975
7013
  },
6976
7014
  onReject: (response ) => {
6977
- logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7015
+ logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6978
7016
  this._stopSendingStats(session);
6979
7017
  this.stopNetworkMonitoring(session);
6980
7018
 
@@ -6997,11 +7035,11 @@ class WebRTCClient extends Emitter {
6997
7035
  }
6998
7036
 
6999
7037
  answer(session , enableVideo ) {
7000
- logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
7038
+ logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
7001
7039
 
7002
7040
  if (!session || !session.accept) {
7003
7041
  const error = 'No session to answer, or not an invitation';
7004
- logger$8.warn(error);
7042
+ logger$4.warn(error);
7005
7043
  return Promise.reject(new Error(error));
7006
7044
  }
7007
7045
  const options = {
@@ -7011,15 +7049,15 @@ class WebRTCClient extends Emitter {
7011
7049
  return session.accept(options).then(() => {
7012
7050
  if (session.isCanceled) {
7013
7051
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
7014
- logger$8.error(message, { id: session.id });
7052
+ logger$4.error(message, { id: session.id });
7015
7053
  this.onCallEnded(session);
7016
7054
 
7017
7055
  throw new CanceledCallError(message);
7018
7056
  }
7019
- logger$8.info('sdk webrtc answer, accepted.');
7057
+ logger$4.info('sdk webrtc answer, accepted.');
7020
7058
  this._onAccepted(session);
7021
7059
  }).catch(e => {
7022
- logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7060
+ logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7023
7061
 
7024
7062
  throw e;
7025
7063
  });
@@ -7027,7 +7065,7 @@ class WebRTCClient extends Emitter {
7027
7065
 
7028
7066
  hangup(session ) {
7029
7067
  const { state, id } = session;
7030
- logger$8.info('sdk webrtc hangup call', { id, state });
7068
+ logger$4.info('sdk webrtc hangup call', { id, state });
7031
7069
 
7032
7070
  try {
7033
7071
  this._stopSendingStats(session);
@@ -7056,7 +7094,7 @@ class WebRTCClient extends Emitter {
7056
7094
 
7057
7095
  return bye();
7058
7096
  } catch (error) {
7059
- logger$8.warn('sdk webrtc hangup, error', error);
7097
+ logger$4.warn('sdk webrtc hangup, error', error);
7060
7098
  }
7061
7099
 
7062
7100
  return null;
@@ -7074,7 +7112,7 @@ class WebRTCClient extends Emitter {
7074
7112
  // Fetch and emit an event at `interval` with session network stats
7075
7113
  startNetworkMonitoring(session , interval = 1000) {
7076
7114
  const sessionId = this.getSipSessionId(session);
7077
- logger$8.info('starting network inspection', { id: sessionId });
7115
+ logger$4.info('starting network inspection', { id: sessionId });
7078
7116
 
7079
7117
  this.sessionNetworkStats[sessionId] = [];
7080
7118
 
@@ -7084,7 +7122,7 @@ class WebRTCClient extends Emitter {
7084
7122
  stopNetworkMonitoring(session ) {
7085
7123
  const sessionId = this.getSipSessionId(session);
7086
7124
  const exists = sessionId in this.networkMonitoringInterval;
7087
- logger$8.info('stopping network inspection', { id: sessionId, exists });
7125
+ logger$4.info('stopping network inspection', { id: sessionId, exists });
7088
7126
 
7089
7127
  if (exists) {
7090
7128
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -7094,17 +7132,17 @@ class WebRTCClient extends Emitter {
7094
7132
  }
7095
7133
 
7096
7134
  reject(session ) {
7097
- logger$8.info('sdk webrtc reject call', { id: session.id });
7135
+ logger$4.info('sdk webrtc reject call', { id: session.id });
7098
7136
 
7099
7137
  try {
7100
7138
  return session.reject ? session.reject() : session.cancel();
7101
7139
  } catch (e) {
7102
- logger$8.warn('Error when rejecting call', e.message, e.stack);
7140
+ logger$4.warn('Error when rejecting call', e.message, e.stack);
7103
7141
  }
7104
7142
  }
7105
7143
 
7106
7144
  async close() {
7107
- logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7145
+ logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7108
7146
  this._cleanupMedia();
7109
7147
  this.connectionPromise = null;
7110
7148
 
@@ -7135,7 +7173,7 @@ class WebRTCClient extends Emitter {
7135
7173
  // eg: "INVITE not rejectable in state Completed"
7136
7174
  }
7137
7175
  this.userAgent = null;
7138
- logger$8.info('sdk webrtc client closed');
7176
+ logger$4.info('sdk webrtc client closed');
7139
7177
  }
7140
7178
 
7141
7179
  getNumber(session ) {
@@ -7148,13 +7186,13 @@ class WebRTCClient extends Emitter {
7148
7186
  }
7149
7187
 
7150
7188
  mute(session ) {
7151
- logger$8.info('sdk webrtc mute', { id: session.id });
7189
+ logger$4.info('sdk webrtc mute', { id: session.id });
7152
7190
 
7153
7191
  this._toggleAudio(session, true);
7154
7192
  }
7155
7193
 
7156
7194
  unmute(session ) {
7157
- logger$8.info('sdk webrtc unmute', { id: session.id });
7195
+ logger$4.info('sdk webrtc unmute', { id: session.id });
7158
7196
 
7159
7197
  this._toggleAudio(session, false);
7160
7198
  }
@@ -7194,13 +7232,13 @@ class WebRTCClient extends Emitter {
7194
7232
  }
7195
7233
 
7196
7234
  toggleCameraOn(session ) {
7197
- logger$8.info('sdk webrtc toggle camera on', { id: session.id });
7235
+ logger$4.info('sdk webrtc toggle camera on', { id: session.id });
7198
7236
 
7199
7237
  this._toggleVideo(session, false);
7200
7238
  }
7201
7239
 
7202
7240
  toggleCameraOff(session ) {
7203
- logger$8.info('sdk webrtc toggle camera off', { id: session.id });
7241
+ logger$4.info('sdk webrtc toggle camera off', { id: session.id });
7204
7242
 
7205
7243
  this._toggleVideo(session, true);
7206
7244
  }
@@ -7209,7 +7247,7 @@ class WebRTCClient extends Emitter {
7209
7247
  const sessionId = this.getSipSessionId(session);
7210
7248
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
7211
7249
 
7212
- logger$8.info('sdk webrtc hold', {
7250
+ logger$4.info('sdk webrtc hold', {
7213
7251
  sessionId,
7214
7252
  keys: Object.keys(this.heldSessions),
7215
7253
  pendingReinvite: !!session.pendingReinvite,
@@ -7258,7 +7296,7 @@ class WebRTCClient extends Emitter {
7258
7296
  const sessionId = this.getSipSessionId(session);
7259
7297
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7260
7298
 
7261
- logger$8.info('sdk webrtc unhold', {
7299
+ logger$4.info('sdk webrtc unhold', {
7262
7300
  sessionId,
7263
7301
  keys: Object.keys(this.heldSessions),
7264
7302
  pendingReinvite: !!session.pendingReinvite,
@@ -7406,7 +7444,7 @@ class WebRTCClient extends Emitter {
7406
7444
  if (!session.sessionDescriptionHandler) {
7407
7445
  return;
7408
7446
  }
7409
- logger$8.info('Sending DTMF', {
7447
+ logger$4.info('Sending DTMF', {
7410
7448
  id: this.getSipSessionId(session),
7411
7449
  tone,
7412
7450
  });
@@ -7422,7 +7460,7 @@ class WebRTCClient extends Emitter {
7422
7460
  transfer(session , target ) {
7423
7461
  this.hold(session);
7424
7462
 
7425
- logger$8.info('Transfering a session', {
7463
+ logger$4.info('Transfering a session', {
7426
7464
  id: this.getSipSessionId(session),
7427
7465
  target,
7428
7466
  });
@@ -7444,17 +7482,17 @@ class WebRTCClient extends Emitter {
7444
7482
  atxfer(session ) {
7445
7483
  this.hold(session);
7446
7484
 
7447
- logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7485
+ logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7448
7486
 
7449
7487
  const result = {
7450
7488
  newSession: null,
7451
7489
  init: async (target ) => {
7452
- logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7490
+ logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7453
7491
 
7454
7492
  result.newSession = await this.call(target);
7455
7493
  },
7456
7494
  complete: () => {
7457
- logger$8.info('webrtc transfer completed', {
7495
+ logger$4.info('webrtc transfer completed', {
7458
7496
  id: this.getSipSessionId(session),
7459
7497
  referId: this.getSipSessionId(result.newSession),
7460
7498
  });
@@ -7475,7 +7513,7 @@ class WebRTCClient extends Emitter {
7475
7513
  return;
7476
7514
  }
7477
7515
 
7478
- logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7516
+ logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
7479
7517
 
7480
7518
  try {
7481
7519
  sipSession.message({
@@ -7517,7 +7555,7 @@ class WebRTCClient extends Emitter {
7517
7555
  }
7518
7556
 
7519
7557
  changeAudioOutputVolume(volume ) {
7520
- logger$8.info('Changing audio output volume', { volume });
7558
+ logger$4.info('Changing audio output volume', { volume });
7521
7559
 
7522
7560
  Object.values(this.audioElements).forEach(audioElement => {
7523
7561
  if (audioElement instanceof HTMLAudioElement) {
@@ -7529,7 +7567,7 @@ class WebRTCClient extends Emitter {
7529
7567
  }
7530
7568
 
7531
7569
  changeAudioOutputDevice(id ) {
7532
- logger$8.info('Changing audio output device', { id });
7570
+ logger$4.info('Changing audio output device', { id });
7533
7571
 
7534
7572
  Object.values(this.audioElements).forEach(audioElement => {
7535
7573
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7546,7 +7584,7 @@ class WebRTCClient extends Emitter {
7546
7584
 
7547
7585
  changeAudioInputDevice(id , session ) {
7548
7586
  const currentId = this.getAudioDeviceId();
7549
- logger$8.info('setting audio input device', { id, currentId, session: !!session });
7587
+ logger$4.info('setting audio input device', { id, currentId, session: !!session });
7550
7588
 
7551
7589
  if (id === currentId) {
7552
7590
  return null;
@@ -7592,7 +7630,7 @@ class WebRTCClient extends Emitter {
7592
7630
 
7593
7631
  setVideoInputDevice(id ) {
7594
7632
  const currentId = this.getVideoDeviceId();
7595
- logger$8.info('setting video input device', { id, currentId });
7633
+ logger$4.info('setting video input device', { id, currentId });
7596
7634
 
7597
7635
  if (id === currentId) {
7598
7636
  return null;
@@ -7617,7 +7655,7 @@ class WebRTCClient extends Emitter {
7617
7655
  const sessionId = this.getSipSessionId(session);
7618
7656
  const localStream = this.getLocalStream(sessionId);
7619
7657
 
7620
- logger$8.info('changing video input device', { id, sessionId });
7658
+ logger$4.info('changing video input device', { id, sessionId });
7621
7659
 
7622
7660
  // Release old video stream
7623
7661
  if (localStream) {
@@ -7685,7 +7723,7 @@ class WebRTCClient extends Emitter {
7685
7723
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7686
7724
  const desktop = newConstraints && newConstraints.desktop;
7687
7725
 
7688
- logger$8.info('Sending reinvite', {
7726
+ logger$4.info('Sending reinvite', {
7689
7727
  id: this.getSipSessionId(sipSession),
7690
7728
  newConstraints,
7691
7729
  conference,
@@ -7723,7 +7761,7 @@ class WebRTCClient extends Emitter {
7723
7761
  sipSession.incomingInviteRequest.message.body = response.message.body;
7724
7762
  }
7725
7763
 
7726
- logger$8.info('on re-INVITE accepted', {
7764
+ logger$4.info('on re-INVITE accepted', {
7727
7765
  id: this.getSipSessionId(sipSession),
7728
7766
  wasMuted,
7729
7767
  shouldDoScreenSharing,
@@ -7741,7 +7779,7 @@ class WebRTCClient extends Emitter {
7741
7779
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7742
7780
  }
7743
7781
 
7744
- return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7782
+ return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7745
7783
  },
7746
7784
  },
7747
7785
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7842,6 +7880,16 @@ class WebRTCClient extends Emitter {
7842
7880
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7843
7881
  }
7844
7882
 
7883
+ // Useful in a react-native environment when remoteMediaStream is not updated
7884
+ getRemoteVideoStreamFromPc(sessionId ) {
7885
+ const pc = this.getPeerConnection(sessionId);
7886
+ if (!pc) {
7887
+ return null;
7888
+ }
7889
+
7890
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7891
+ }
7892
+
7845
7893
  hasVideo(sessionId ) {
7846
7894
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7847
7895
  }
@@ -7888,7 +7936,7 @@ class WebRTCClient extends Emitter {
7888
7936
  }
7889
7937
 
7890
7938
  startHeartbeat() {
7891
- logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7939
+ logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7892
7940
  if (!this.userAgent) {
7893
7941
  this.heartbeat.stop();
7894
7942
  return;
@@ -7901,7 +7949,7 @@ class WebRTCClient extends Emitter {
7901
7949
  }
7902
7950
 
7903
7951
  stopHeartbeat() {
7904
- logger$8.info('sdk webrtc stop heartbeat');
7952
+ logger$4.info('sdk webrtc stop heartbeat');
7905
7953
  this.heartbeat.stop();
7906
7954
  }
7907
7955
 
@@ -7922,7 +7970,7 @@ class WebRTCClient extends Emitter {
7922
7970
  }
7923
7971
 
7924
7972
  attemptReconnection() {
7925
- logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7973
+ logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
7926
7974
  if (!this.userAgent) {
7927
7975
  return;
7928
7976
  }
@@ -7947,7 +7995,7 @@ class WebRTCClient extends Emitter {
7947
7995
  return;
7948
7996
  }
7949
7997
 
7950
- logger$8.info('setting local media stream', {
7998
+ logger$4.info('setting local media stream', {
7951
7999
  sipSessionId,
7952
8000
  tracks: newStream ? newStream.getTracks() : null,
7953
8001
  });
@@ -7964,7 +8012,7 @@ class WebRTCClient extends Emitter {
7964
8012
 
7965
8013
  const oldStream = this.getLocalStream(sipSessionId);
7966
8014
 
7967
- logger$8.info('updating local stream', {
8015
+ logger$4.info('updating local stream', {
7968
8016
  sipSessionId,
7969
8017
  oldStream: !!oldStream,
7970
8018
  tracks: newStream.getTracks(),
@@ -7984,7 +8032,7 @@ class WebRTCClient extends Emitter {
7984
8032
  const remoteStream = this.getRemoteStream(sessionId);
7985
8033
  const pc = this.getPeerConnection(sessionId);
7986
8034
 
7987
- logger$8.info('Updating remote stream', {
8035
+ logger$4.info('Updating remote stream', {
7988
8036
  sessionId,
7989
8037
  tracks: remoteStream ? remoteStream.getTracks() : null,
7990
8038
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -8010,7 +8058,7 @@ class WebRTCClient extends Emitter {
8010
8058
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
8011
8059
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
8012
8060
 
8013
- logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8061
+ logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8014
8062
 
8015
8063
  return {
8016
8064
  constraints: {
@@ -8059,7 +8107,7 @@ class WebRTCClient extends Emitter {
8059
8107
  }
8060
8108
 
8061
8109
  _onTransportError() {
8062
- logger$8.error('on transport error');
8110
+ logger$4.error('on transport error');
8063
8111
  this.eventEmitter.emit(TRANSPORT_ERROR);
8064
8112
  this.attemptReconnection();
8065
8113
  }
@@ -8068,7 +8116,7 @@ class WebRTCClient extends Emitter {
8068
8116
  const body = message && typeof message === 'object' ? message.data : message;
8069
8117
  if (body && body.indexOf('200 OK') !== -1) {
8070
8118
  if (this.hasHeartbeat()) {
8071
- logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8119
+ logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8072
8120
 
8073
8121
  this.heartbeat.onHeartbeat();
8074
8122
  if (this.heartbeatCb) {
@@ -8079,7 +8127,7 @@ class WebRTCClient extends Emitter {
8079
8127
  }
8080
8128
 
8081
8129
  async _onHeartbeatTimeout() {
8082
- logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8130
+ logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8083
8131
 
8084
8132
  if (this.heartbeatTimeoutCb) {
8085
8133
  this.heartbeatTimeoutCb();
@@ -8091,7 +8139,7 @@ class WebRTCClient extends Emitter {
8091
8139
  try {
8092
8140
  await this.userAgent.transport.disconnect();
8093
8141
  } catch (e) {
8094
- logger$8.error('Transport disconnection after heartbeat timeout, error', e);
8142
+ logger$4.error('Transport disconnection after heartbeat timeout, error', e);
8095
8143
  }
8096
8144
  }
8097
8145
 
@@ -8124,31 +8172,31 @@ class WebRTCClient extends Emitter {
8124
8172
  }
8125
8173
 
8126
8174
  _connectIfNeeded() {
8127
- logger$8.info('connect if needed, checking', { connected: this.isConnected() });
8175
+ logger$4.info('connect if needed, checking', { connected: this.isConnected() });
8128
8176
  if (!this.userAgent) {
8129
- logger$8.info('need to recreate User Agent');
8177
+ logger$4.info('need to recreate User Agent');
8130
8178
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
8131
8179
  }
8132
8180
 
8133
8181
  if (this.isConnected()) {
8134
- logger$8.info('webrtc sdk, already connected');
8182
+ logger$4.info('webrtc sdk, already connected');
8135
8183
  return Promise.resolve();
8136
8184
  }
8137
8185
 
8138
8186
  if (this.isConnecting()) {
8139
- logger$8.info('webrtc sdk, already connecting...');
8187
+ logger$4.info('webrtc sdk, already connecting...');
8140
8188
 
8141
8189
  this.connectionPromise = this.userAgent.transport.connectPromise;
8142
8190
  return this.connectionPromise;
8143
8191
  }
8144
8192
 
8145
8193
  if (this.connectionPromise) {
8146
- logger$8.info('webrtc sdk, connection promise connecting...');
8194
+ logger$4.info('webrtc sdk, connection promise connecting...');
8147
8195
  // $FlowFixMe
8148
8196
  return this.connectionPromise;
8149
8197
  }
8150
8198
 
8151
- logger$8.info('WebRTC UA needs to connect');
8199
+ logger$4.info('WebRTC UA needs to connect');
8152
8200
 
8153
8201
  // Force UA to reconnect
8154
8202
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8273,7 +8321,7 @@ class WebRTCClient extends Emitter {
8273
8321
 
8274
8322
  sdh.peerConnectionDelegate = {
8275
8323
  onicecandidateerror: (error ) => {
8276
- logger$8.error('on icecandidate error', {
8324
+ logger$4.error('on icecandidate error', {
8277
8325
  address: error.address,
8278
8326
  port: error.port,
8279
8327
  errorCode: error.errorCode,
@@ -8302,7 +8350,7 @@ class WebRTCClient extends Emitter {
8302
8350
  updatedNumber = session.assertedIdentity.uri.normal.user;
8303
8351
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8304
8352
  }
8305
- logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8353
+ logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8306
8354
 
8307
8355
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8308
8356
 
@@ -8318,12 +8366,12 @@ class WebRTCClient extends Emitter {
8318
8366
 
8319
8367
  this._setupMedias(session);
8320
8368
 
8321
- return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8369
+ return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8322
8370
  };
8323
8371
  }
8324
8372
 
8325
8373
  _onAccepted(session , sessionDialog , withEvent = true) {
8326
- logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8374
+ logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8327
8375
 
8328
8376
  this.storeSipSession(session);
8329
8377
 
@@ -8335,14 +8383,14 @@ class WebRTCClient extends Emitter {
8335
8383
  const onTrack = (event ) => {
8336
8384
  const isAudioOnly = this._isAudioOnly(session);
8337
8385
  const { kind, label, readyState, id, muted } = event.track;
8338
- logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8386
+ logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8339
8387
 
8340
8388
  // Stop video track in audio only mode
8341
8389
  if (isAudioOnly && kind === 'video') {
8342
8390
  event.track.stop();
8343
8391
  }
8344
8392
 
8345
- this.eventEmitter.emit(ON_TRACK$1, session, event);
8393
+ this.eventEmitter.emit(ON_TRACK, session, event);
8346
8394
  };
8347
8395
 
8348
8396
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8352,8 +8400,9 @@ class WebRTCClient extends Emitter {
8352
8400
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8353
8401
 
8354
8402
  pc.oniceconnectionstatechange = () => {
8403
+ logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
8355
8404
  if (pc.iceConnectionState === 'disconnected') {
8356
- this.eventEmitter.emit(ON_DISCONNECTED$1);
8405
+ this.eventEmitter.emit(ON_DISCONNECTED);
8357
8406
  }
8358
8407
  };
8359
8408
 
@@ -8524,10 +8573,10 @@ class WebRTCClient extends Emitter {
8524
8573
 
8525
8574
  _stopSendingStats(session ) {
8526
8575
  const sessionId = this.getSipSessionId(session);
8527
- logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8576
+ logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8528
8577
 
8529
8578
  if (sessionId in this.statsIntervals) {
8530
- logger$8.trace('Stop sending stats for call', { sessionId });
8579
+ logger$4.trace('Stop sending stats for call', { sessionId });
8531
8580
  this.statsIntervals[sessionId]();
8532
8581
  delete this.statsIntervals[sessionId];
8533
8582
  }
@@ -8543,7 +8592,7 @@ class WebRTCClient extends Emitter {
8543
8592
  try {
8544
8593
  await this.userAgent.transport.disconnect();
8545
8594
  } catch (e) {
8546
- logger$8.error('WebRTC transport disconnect, error', e);
8595
+ logger$4.error('WebRTC transport disconnect, error', e);
8547
8596
  }
8548
8597
  }
8549
8598
  }
@@ -8580,25 +8629,25 @@ class WebRTCClient extends Emitter {
8580
8629
 
8581
8630
  stats.forEach(report => {
8582
8631
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8583
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8632
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8584
8633
  }
8585
8634
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8586
- audioBytesSent += report.bytesSent;
8635
+ audioBytesSent += Number(report.bytesSent);
8587
8636
  }
8588
8637
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8589
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8638
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8590
8639
  }
8591
8640
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8592
- packetsLost += report.packetsLost;
8593
- networkStats.packetsReceived = report.packetsReceived;
8594
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8641
+ packetsLost += Number(report.packetsLost);
8642
+ networkStats.packetsReceived = Number(report.packetsReceived);
8643
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8595
8644
  }
8596
8645
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8597
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8646
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8598
8647
  }
8599
8648
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8600
8649
  if ('framesPerSecond' in report) {
8601
- networkStats.framesPerSecond = report.framesPerSecond;
8650
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8602
8651
  }
8603
8652
  if ('framerateMean' in report) {
8604
8653
  // framerateMean is only available in FF
@@ -8606,34 +8655,38 @@ class WebRTCClient extends Emitter {
8606
8655
  }
8607
8656
  }
8608
8657
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8609
- packetsLost += report.packetsLost;
8610
- networkStats.roundTripTime = report.roundTripTime;
8611
- networkStats.jitter = report.jitter;
8658
+ packetsLost += Number(report.packetsLost);
8659
+ networkStats.roundTripTime = Number(report.roundTripTime);
8660
+ networkStats.jitter = Number(report.jitter);
8612
8661
  }
8613
8662
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8614
- packetsLost += report.packetsLost;
8663
+ packetsLost += Number(report.packetsLost);
8615
8664
  }
8616
8665
  if (report.type === 'transport') {
8617
- transportSent += report.bytesSent;
8618
- transportReceived += report.bytesReceived;
8666
+ transportSent += Number(report.bytesSent);
8667
+ transportReceived += Number(report.bytesReceived);
8619
8668
  }
8620
8669
  });
8621
8670
 
8622
8671
  networkStats.packetsLost = packetsLost;
8623
- networkStats.audioBytesSent = audioBytesSent;
8672
+ networkStats.totalAudioBytesSent = audioBytesSent;
8673
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8674
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8624
8675
  networkStats.audioBytesReceived = audioBytesReceived;
8625
- networkStats.videoBytesSent = videoBytesSent;
8626
- networkStats.videoBytesReceived = videoBytesReceived;
8676
+ networkStats.totalVideoBytesSent = videoBytesSent;
8677
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8678
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8679
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8680
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8627
8681
  networkStats.transportSent = transportSent;
8628
- networkStats.transportReceived = transportReceived;
8629
-
8630
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8631
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8632
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8682
+ networkStats.totalTransportReceived = transportReceived;
8683
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8633
8684
 
8634
- networkStats.bandwidth = bandwidth;
8685
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8686
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8687
+ + networkStats.transportSent;
8635
8688
 
8636
- this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8689
+ this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8637
8690
  this.sessionNetworkStats[sessionId].push(networkStats);
8638
8691
  }
8639
8692
 
@@ -8661,8 +8714,8 @@ const ON_CALL_FAILED = 'onCallFailed';
8661
8714
  const ON_CALL_ENDED = 'onCallEnded';
8662
8715
  const ON_CALL_ENDING = 'onCallEnding';
8663
8716
  const ON_MESSAGE = 'onMessage';
8664
- const ON_REINVITE = 'reinvite';
8665
- const ON_TRACK = 'onTrack';
8717
+ const ON_REINVITE$1 = 'reinvite';
8718
+ const ON_TRACK$1 = 'onTrack';
8666
8719
  const ON_AUDIO_STREAM = 'onAudioStream';
8667
8720
  const ON_VIDEO_STREAM = 'onVideoStream';
8668
8721
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8677,15 +8730,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8677
8730
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8678
8731
  const ON_CALL_ERROR = 'onCallError';
8679
8732
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8680
- const ON_NETWORK_STATS = 'onNetworkStats';
8733
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
8681
8734
  const ON_CHAT = 'phone/ON_CHAT';
8682
8735
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8683
- const ON_DISCONNECTED = 'onDisconnected';
8736
+ const ON_DISCONNECTED$1 = 'onDisconnected';
8684
8737
 
8685
8738
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8686
8739
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8687
8740
 
8688
- const events = [
8741
+ const events$1 = [
8689
8742
  ON_USER_AGENT,
8690
8743
  ON_REGISTERED,
8691
8744
  ON_UNREGISTERED,
@@ -8703,8 +8756,8 @@ const events = [
8703
8756
  ON_CALL_FAILED,
8704
8757
  ON_CALL_ENDED,
8705
8758
  ON_MESSAGE,
8706
- ON_REINVITE,
8707
- ON_TRACK,
8759
+ ON_REINVITE$1,
8760
+ ON_TRACK$1,
8708
8761
  ON_AUDIO_STREAM,
8709
8762
  ON_VIDEO_STREAM,
8710
8763
  ON_REMOVE_STREAM,
@@ -8719,11 +8772,11 @@ const events = [
8719
8772
  ON_CALL_ERROR,
8720
8773
  ON_CHAT,
8721
8774
  ON_SIGNAL,
8722
- ON_NETWORK_STATS,
8723
- ON_DISCONNECTED,
8775
+ ON_NETWORK_STATS$1,
8776
+ ON_DISCONNECTED$1,
8724
8777
  ];
8725
8778
 
8726
- const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8779
+ const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
8727
8780
 
8728
8781
  class WebRTCPhone extends Emitter {
8729
8782
 
@@ -8796,7 +8849,7 @@ class WebRTCPhone extends Emitter {
8796
8849
  }).catch(error => {
8797
8850
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8798
8851
  console.error('register error', error, error.message, error.stack);
8799
- logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8852
+ logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
8800
8853
  });
8801
8854
  }
8802
8855
 
@@ -8811,7 +8864,7 @@ class WebRTCPhone extends Emitter {
8811
8864
  if (!this.client) {
8812
8865
  return;
8813
8866
  }
8814
- logger$7.info('WebRTC phone stop');
8867
+ logger$5.info('WebRTC phone stop');
8815
8868
  this.client.stop();
8816
8869
  }
8817
8870
 
@@ -8826,7 +8879,7 @@ class WebRTCPhone extends Emitter {
8826
8879
  async sendReinvite(callSession , constraints = null, conference = false,
8827
8880
  audioOnly = false, iceRestart = false) {
8828
8881
  const sipSession = this.findSipSession(callSession);
8829
- logger$7.info('WebRTC phone - send reinvite', {
8882
+ logger$5.info('WebRTC phone - send reinvite', {
8830
8883
  sessionId: sipSession ? sipSession.id : null,
8831
8884
  constraints,
8832
8885
  audioOnly,
@@ -8863,7 +8916,7 @@ class WebRTCPhone extends Emitter {
8863
8916
  }
8864
8917
 
8865
8918
  startHeartbeat() {
8866
- logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8919
+ logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8867
8920
  if (!this.client || this.client.hasHeartbeat()) {
8868
8921
  return;
8869
8922
  }
@@ -8872,7 +8925,7 @@ class WebRTCPhone extends Emitter {
8872
8925
  }
8873
8926
 
8874
8927
  stopHeartbeat() {
8875
- logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8928
+ logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8876
8929
  if (!this.client) {
8877
8930
  return;
8878
8931
  }
@@ -8889,7 +8942,7 @@ class WebRTCPhone extends Emitter {
8889
8942
  }
8890
8943
 
8891
8944
  reconnect() {
8892
- logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8945
+ logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
8893
8946
  if (!this.client) {
8894
8947
  return;
8895
8948
  }
@@ -8930,10 +8983,15 @@ class WebRTCPhone extends Emitter {
8930
8983
  return false;
8931
8984
  }
8932
8985
 
8933
- logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8986
+ logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8934
8987
 
8935
8988
  this.client.downgradeToAudio(sipSession);
8936
8989
 
8990
+ if (callSession) {
8991
+ callSession.cameraEnabled = false;
8992
+ this._updateCallSession(callSession);
8993
+ }
8994
+
8937
8995
  if (withMessage) {
8938
8996
  this._sendReinviteMessage(callSession, false);
8939
8997
  }
@@ -8948,7 +9006,7 @@ class WebRTCPhone extends Emitter {
8948
9006
  return Promise.resolve(false);
8949
9007
  }
8950
9008
 
8951
- logger$7.info('Upgrade to video', {
9009
+ logger$5.info('Upgrade to video', {
8952
9010
  id: callSession ? callSession.getId() : null,
8953
9011
  constraints,
8954
9012
  isConference,
@@ -8961,6 +9019,11 @@ class WebRTCPhone extends Emitter {
8961
9019
 
8962
9020
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
8963
9021
 
9022
+ if (callSession) {
9023
+ callSession.cameraEnabled = true;
9024
+ this._updateCallSession(callSession);
9025
+ }
9026
+
8964
9027
  // If no stream is returned, it means we have to reinvite
8965
9028
  if (!newStream) {
8966
9029
  return true;
@@ -8983,7 +9046,7 @@ class WebRTCPhone extends Emitter {
8983
9046
 
8984
9047
  _sendReinviteMessage(callSession , isUpgrade ) {
8985
9048
  const sipSession = this.findSipSession(callSession);
8986
- logger$7.info('Sending reinvite message', {
9049
+ logger$5.info('Sending reinvite message', {
8987
9050
  id: callSession ? callSession.getId() : null,
8988
9051
  isUpgrade,
8989
9052
  });
@@ -9009,11 +9072,14 @@ class WebRTCPhone extends Emitter {
9009
9072
  // Monkey patch to know when canceled with the CANCEL message
9010
9073
  const onCancel = sipSession._onCancel.bind(sipSession);
9011
9074
  sipSession._onCancel = (message ) => {
9012
- logger$7.trace('on sip session canceled', { callId: message.callId });
9075
+ logger$5.trace('on sip session canceled', { callId: message.callId });
9013
9076
 
9014
9077
  onCancel(message);
9015
9078
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9016
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9079
+ const callSession = this._createCallSession(sipSession);
9080
+ delete this.callSessions[callSession.getId()];
9081
+
9082
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9017
9083
  };
9018
9084
  } else if (sipSession instanceof invitation.Invitation) {
9019
9085
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9034,17 +9100,19 @@ class WebRTCPhone extends Emitter {
9034
9100
  this.audioOutputVolume,
9035
9101
  );
9036
9102
  case sessionState.SessionState.Terminating:
9037
- logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9103
+ logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9038
9104
 
9039
9105
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9040
9106
 
9041
9107
  break;
9042
9108
  case sessionState.SessionState.Terminated: {
9043
- logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9109
+ logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9044
9110
 
9111
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9112
+ const callSession = this._createCallSession(sipSession);
9045
9113
  const wasCurrentSession = this._onCallTerminated(sipSession);
9046
9114
 
9047
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9115
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9048
9116
  }
9049
9117
  }
9050
9118
  });
@@ -9060,7 +9128,7 @@ class WebRTCPhone extends Emitter {
9060
9128
  const [stream] = event.streams;
9061
9129
  const kind = event && event.track && event.track.kind;
9062
9130
 
9063
- logger$7.info('on track stream called on the peer connection', {
9131
+ logger$5.info('on track stream called on the peer connection', {
9064
9132
  callId: this.getSipSessionId(sipSession),
9065
9133
  streamId: stream ? stream.id : null,
9066
9134
  tracks: stream ? stream.getTracks() : null,
@@ -9080,7 +9148,7 @@ class WebRTCPhone extends Emitter {
9080
9148
  };
9081
9149
 
9082
9150
  peerConnection.onremovestream = event => {
9083
- logger$7.info('on remove stream called on the peer connection', {
9151
+ logger$5.info('on remove stream called on the peer connection', {
9084
9152
  id: event.stream.id,
9085
9153
  tracks: event.stream.getTracks(),
9086
9154
  });
@@ -9090,7 +9158,7 @@ class WebRTCPhone extends Emitter {
9090
9158
  }
9091
9159
 
9092
9160
  async startScreenSharing(constraints , callSession ) {
9093
- logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9161
+ logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9094
9162
 
9095
9163
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9096
9164
  if (!screenShareStream) {
@@ -9130,7 +9198,7 @@ class WebRTCPhone extends Emitter {
9130
9198
  return;
9131
9199
  }
9132
9200
 
9133
- logger$7.info('WebRTC phone - stop screen sharing', {
9201
+ logger$5.info('WebRTC phone - stop screen sharing', {
9134
9202
  restoreLocalStream,
9135
9203
  });
9136
9204
 
@@ -9186,24 +9254,26 @@ class WebRTCPhone extends Emitter {
9186
9254
  const pc = this.client.getPeerConnection(sipSessionId);
9187
9255
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9188
9256
 
9189
- logger$7.info('WebRTC phone - on screensharing', {
9257
+ logger$5.info('WebRTC phone - on screensharing', {
9190
9258
  hadVideo,
9191
9259
  id: this.getSipSessionId(sipSession),
9192
9260
  screenTrack,
9193
9261
  });
9194
9262
 
9195
- screenTrack.onended = () => {
9196
- logger$7.info('WebRTC phone - on screenshare ended', {
9197
- hadVideo,
9198
- id: this.getSipSessionId(sipSession),
9199
- screenTrack,
9200
- });
9263
+ if (screenTrack) {
9264
+ screenTrack.onended = () => {
9265
+ logger$5.info('WebRTC phone - on screenshare ended', {
9266
+ hadVideo,
9267
+ id: this.getSipSessionId(sipSession),
9268
+ screenTrack,
9269
+ });
9201
9270
 
9202
- this.eventEmitter.emit(
9203
- ON_SHARE_SCREEN_ENDING,
9204
- this._createCallSession(sipSession, callSession),
9205
- );
9206
- };
9271
+ this.eventEmitter.emit(
9272
+ ON_SHARE_SCREEN_ENDING,
9273
+ this._createCallSession(sipSession, callSession),
9274
+ );
9275
+ };
9276
+ }
9207
9277
 
9208
9278
  this.currentScreenShare = {
9209
9279
  stream: screenStream,
@@ -9223,7 +9293,7 @@ class WebRTCPhone extends Emitter {
9223
9293
  }
9224
9294
 
9225
9295
  _onCallAccepted(sipSession , cameraEnabled ) {
9226
- logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9296
+ logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9227
9297
 
9228
9298
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9229
9299
  this.currentSipSession = sipSession;
@@ -9241,7 +9311,7 @@ class WebRTCPhone extends Emitter {
9241
9311
  }
9242
9312
 
9243
9313
  changeAudioDevice(id ) {
9244
- logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9314
+ logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9245
9315
  this.audioOutputDeviceId = id;
9246
9316
  this.client.changeAudioOutputDevice(id);
9247
9317
  }
@@ -9251,14 +9321,14 @@ class WebRTCPhone extends Emitter {
9251
9321
  }
9252
9322
 
9253
9323
  changeRingDevice(id ) {
9254
- logger$7.info('WebRTC phone - changing ring device', { id });
9324
+ logger$5.info('WebRTC phone - changing ring device', { id });
9255
9325
 
9256
9326
  this.audioRingDeviceId = id;
9257
9327
  }
9258
9328
 
9259
9329
  // volume is a value between 0 and 1
9260
9330
  changeAudioVolume(volume ) {
9261
- logger$7.info('WebRTC phone - changing audio volume', { volume });
9331
+ logger$5.info('WebRTC phone - changing audio volume', { volume });
9262
9332
 
9263
9333
  this.audioOutputVolume = volume;
9264
9334
  this.client.changeAudioOutputVolume(volume);
@@ -9266,31 +9336,31 @@ class WebRTCPhone extends Emitter {
9266
9336
 
9267
9337
  // volume is a value between 0 and 1
9268
9338
  changeRingVolume(volume ) {
9269
- logger$7.info('WebRTC phone - changing ring volume', { volume });
9339
+ logger$5.info('WebRTC phone - changing ring volume', { volume });
9270
9340
 
9271
9341
  this.audioRingVolume = volume;
9272
9342
  }
9273
9343
 
9274
9344
  changeAudioInputDevice(id ) {
9275
- logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9345
+ logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9276
9346
 
9277
9347
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9278
9348
  }
9279
9349
 
9280
9350
  changeVideoInputDevice(id ) {
9281
- logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9351
+ logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9282
9352
 
9283
9353
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9284
9354
  }
9285
9355
 
9286
9356
  changeSessionVideoInputDevice(id ) {
9287
- logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9357
+ logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9288
9358
 
9289
9359
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9290
9360
  }
9291
9361
 
9292
9362
  _onCallTerminated(sipSession ) {
9293
- logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9363
+ logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9294
9364
 
9295
9365
  const callSession = this._createCallSession(sipSession);
9296
9366
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -9324,7 +9394,7 @@ class WebRTCPhone extends Emitter {
9324
9394
  const hasIncomingCallSession = this.hasIncomingCallSession();
9325
9395
 
9326
9396
  // Re-trigger incoming call event for remaining incoming calls
9327
- logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9397
+ logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9328
9398
  sipId: sipSession.id,
9329
9399
  shouldRetrigger,
9330
9400
  hasIncomingCallSession,
@@ -9415,37 +9485,37 @@ class WebRTCPhone extends Emitter {
9415
9485
 
9416
9486
  // Deprecated
9417
9487
  getLocalStreamForCall(callSession ) {
9418
- logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9488
+ logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9419
9489
 
9420
9490
  return this.getLocalStream(callSession);
9421
9491
  }
9422
9492
 
9423
9493
  // Deprecated
9424
9494
  getRemoteStreamForCall(callSession ) {
9425
- logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9495
+ logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9426
9496
 
9427
9497
  return this.getRemoteVideoStream(callSession);
9428
9498
  }
9429
9499
 
9430
9500
  getRemoteStreamsForCall(callSession ) {
9431
- logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9501
+ logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9432
9502
 
9433
9503
  return this.getRemoteStream(callSession);
9434
9504
  }
9435
9505
 
9436
9506
  accept(callSession , cameraEnabled ) {
9437
- logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9507
+ logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9438
9508
  if (this.currentSipSession) {
9439
9509
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9440
9510
  }
9441
9511
 
9442
9512
  if (!callSession) {
9443
- logger$7.warn('no CallSession to accept.');
9513
+ logger$5.warn('no CallSession to accept.');
9444
9514
  return Promise.resolve(null);
9445
9515
  }
9446
9516
 
9447
9517
  if (callSession.getId() in this.acceptedSessions) {
9448
- logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9518
+ logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9449
9519
  return Promise.resolve(callSession.sipCallId);
9450
9520
  }
9451
9521
 
@@ -9457,24 +9527,24 @@ class WebRTCPhone extends Emitter {
9457
9527
  const sipSession = this.client.getSipSession(callSession.getId());
9458
9528
  if (sipSession) {
9459
9529
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9460
- logger$7.warn('Trying to answer a terminated sipSession.');
9530
+ logger$5.warn('Trying to answer a terminated sipSession.');
9461
9531
 
9462
9532
  return Promise.resolve(null);
9463
9533
  }
9464
9534
 
9465
- logger$7.info('accept call, session found', { sipId: sipSession.id });
9535
+ logger$5.info('accept call, session found', { sipId: sipSession.id });
9466
9536
 
9467
9537
  // $FlowFixMe
9468
9538
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9469
9539
  return callSession.sipCallId;
9470
9540
  }).catch(e => {
9471
- logger$7.error(e);
9541
+ logger$5.error(e);
9472
9542
  this.endCurrentCall(callSession);
9473
9543
  throw e;
9474
9544
  });
9475
9545
  }
9476
9546
 
9477
- logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9547
+ logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9478
9548
 
9479
9549
  return Promise.resolve(null);
9480
9550
  }
@@ -9484,7 +9554,7 @@ class WebRTCPhone extends Emitter {
9484
9554
  }
9485
9555
 
9486
9556
  async reject(callSession ) {
9487
- logger$7.info('reject WebRTC called', { id: callSession.getId() });
9557
+ logger$5.info('reject WebRTC called', { id: callSession.getId() });
9488
9558
 
9489
9559
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9490
9560
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9496,14 +9566,14 @@ class WebRTCPhone extends Emitter {
9496
9566
 
9497
9567
  const sipSession = this.findSipSession(callSession);
9498
9568
  if (sipSession) {
9499
- logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
9569
+ logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9500
9570
 
9501
9571
  this.client.hangup(sipSession);
9502
9572
  }
9503
9573
  }
9504
9574
 
9505
9575
  async ignore(callSession ) {
9506
- logger$7.info('WebRTC ignore', { id: callSession.getId() });
9576
+ logger$5.info('WebRTC ignore', { id: callSession.getId() });
9507
9577
 
9508
9578
  // kill the ring
9509
9579
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9515,14 +9585,14 @@ class WebRTCPhone extends Emitter {
9515
9585
  const sipSession = this.findSipSession(callSession);
9516
9586
 
9517
9587
  if (sipSession) {
9518
- logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
9588
+ logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9519
9589
 
9520
9590
  return this.client.atxfer(sipSession);
9521
9591
  }
9522
9592
  }
9523
9593
 
9524
9594
  hold(callSession , withEvent = true, isConference = false) {
9525
- logger$7.info('WebRTC hold', { id: callSession.getId() });
9595
+ logger$5.info('WebRTC hold', { id: callSession.getId() });
9526
9596
 
9527
9597
  const sipSession = this.findSipSession(callSession);
9528
9598
 
@@ -9537,18 +9607,18 @@ class WebRTCPhone extends Emitter {
9537
9607
  }
9538
9608
 
9539
9609
  resume(callSession , isConference = false, withEvent = true) {
9540
- logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9610
+ logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9541
9611
 
9542
9612
  const sipSession = this.findSipSession(callSession);
9543
9613
  if (!sipSession) {
9544
9614
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9545
9615
  }
9546
9616
 
9547
- logger$7.info('WebRTC resuming', { sipId: sipSession.id });
9617
+ logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9548
9618
 
9549
9619
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9550
9620
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9551
- logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9621
+ logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9552
9622
  this.holdSipSession(this.currentSipSession, callSession);
9553
9623
  }
9554
9624
 
@@ -9573,7 +9643,7 @@ class WebRTCPhone extends Emitter {
9573
9643
  const sessionId = this.getSipSessionId(sipSession);
9574
9644
  const hasVideo = this.client.hasLocalVideo(sessionId);
9575
9645
 
9576
- logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9646
+ logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9577
9647
 
9578
9648
  // Stop screenshre if needed
9579
9649
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9604,7 +9674,7 @@ class WebRTCPhone extends Emitter {
9604
9674
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9605
9675
  }
9606
9676
  const sessionId = this.getSipSessionId(sipSession);
9607
- logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9677
+ logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
9608
9678
 
9609
9679
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9610
9680
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9648,14 +9718,14 @@ class WebRTCPhone extends Emitter {
9648
9718
  }
9649
9719
 
9650
9720
  mute(callSession , withEvent = true) {
9651
- logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9721
+ logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9652
9722
 
9653
9723
  const sipSession = this.findSipSession(callSession);
9654
9724
  if (!sipSession) {
9655
9725
  return;
9656
9726
  }
9657
9727
 
9658
- logger$7.info('WebRTC muting', { sipId: sipSession.id });
9728
+ logger$5.info('WebRTC muting', { sipId: sipSession.id });
9659
9729
  this.client.mute(sipSession);
9660
9730
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9661
9731
 
@@ -9669,14 +9739,14 @@ class WebRTCPhone extends Emitter {
9669
9739
  }
9670
9740
 
9671
9741
  unmute(callSession , withEvent = true) {
9672
- logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9742
+ logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9673
9743
 
9674
9744
  const sipSession = this.findSipSession(callSession);
9675
9745
  if (!sipSession) {
9676
9746
  return;
9677
9747
  }
9678
9748
 
9679
- logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9749
+ logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
9680
9750
  this.client.unmute(sipSession);
9681
9751
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9682
9752
 
@@ -9703,7 +9773,7 @@ class WebRTCPhone extends Emitter {
9703
9773
  if (!sipSession) {
9704
9774
  return;
9705
9775
  }
9706
- logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9776
+ logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
9707
9777
 
9708
9778
  this.client.toggleCameraOn(sipSession);
9709
9779
 
@@ -9715,7 +9785,7 @@ class WebRTCPhone extends Emitter {
9715
9785
  if (!sipSession) {
9716
9786
  return;
9717
9787
  }
9718
- logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9788
+ logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
9719
9789
 
9720
9790
  this.client.toggleCameraOff(sipSession);
9721
9791
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9727,7 +9797,7 @@ class WebRTCPhone extends Emitter {
9727
9797
  return;
9728
9798
  }
9729
9799
 
9730
- logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9800
+ logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
9731
9801
  this.client.sendDTMF(sipSession, tone);
9732
9802
  }
9733
9803
 
@@ -9735,7 +9805,7 @@ class WebRTCPhone extends Emitter {
9735
9805
  // @TODO: line is not used here
9736
9806
  async makeCall(number , line , cameraEnabled ,
9737
9807
  audioOnly = false, conference = false) {
9738
- logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9808
+ logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9739
9809
  if (!number) {
9740
9810
  return Promise.resolve(null);
9741
9811
  }
@@ -9745,7 +9815,7 @@ class WebRTCPhone extends Emitter {
9745
9815
  }
9746
9816
  if (this.currentSipSession) {
9747
9817
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9748
- logger$7.warn('Unable to hold current session when making another call', e);
9818
+ logger$5.warn('Unable to hold current session when making another call', e);
9749
9819
  });
9750
9820
  }
9751
9821
 
@@ -9755,7 +9825,7 @@ class WebRTCPhone extends Emitter {
9755
9825
  this._bindEvents(sipSession);
9756
9826
  } catch (error) {
9757
9827
  console.warn(error);
9758
- logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9828
+ logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9759
9829
  return Promise.resolve(null);
9760
9830
  }
9761
9831
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -9783,7 +9853,7 @@ class WebRTCPhone extends Emitter {
9783
9853
  return;
9784
9854
  }
9785
9855
 
9786
- logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9856
+ logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
9787
9857
 
9788
9858
  this.client.transfer(sipSession, target);
9789
9859
  }
@@ -9792,7 +9862,7 @@ class WebRTCPhone extends Emitter {
9792
9862
  const sipSession = this.client.getSipSession(source.sipCallId);
9793
9863
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9794
9864
 
9795
- logger$7.info('WebRTC indirect transfer', {
9865
+ logger$5.info('WebRTC indirect transfer', {
9796
9866
  sipId: sipSession ? sipSession.id : null,
9797
9867
  target: sipSessionTarget ? sipSessionTarget.id : null,
9798
9868
  });
@@ -9831,7 +9901,7 @@ class WebRTCPhone extends Emitter {
9831
9901
  return false;
9832
9902
  }
9833
9903
 
9834
- logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9904
+ logger$5.info('WebRTC hangup', { sipId: sipSession.id });
9835
9905
 
9836
9906
  const sipSessionId = this.getSipSessionId(sipSession);
9837
9907
 
@@ -9877,7 +9947,7 @@ class WebRTCPhone extends Emitter {
9877
9947
  endCurrentCall(callSession ) {
9878
9948
  const isCurrent = this.isCurrentCallSipSession(callSession);
9879
9949
 
9880
- logger$7.info('Ending current call', {
9950
+ logger$5.info('Ending current call', {
9881
9951
  id: callSession ? callSession.getId() : null,
9882
9952
  isCurrent,
9883
9953
  });
@@ -9901,7 +9971,7 @@ class WebRTCPhone extends Emitter {
9901
9971
  }
9902
9972
 
9903
9973
  async close() {
9904
- logger$7.info('WebRTC close');
9974
+ logger$5.info('WebRTC close');
9905
9975
 
9906
9976
  try {
9907
9977
  await Promise.race([
@@ -9909,7 +9979,7 @@ class WebRTCPhone extends Emitter {
9909
9979
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9910
9980
  ]);
9911
9981
  } catch (e) {
9912
- logger$7.error('WebRTC close, unregister error', e);
9982
+ logger$5.error('WebRTC close, unregister error', e);
9913
9983
  }
9914
9984
 
9915
9985
  this.client.close();
@@ -9927,12 +9997,12 @@ class WebRTCPhone extends Emitter {
9927
9997
  }
9928
9998
 
9929
9999
  enableRinging() {
9930
- logger$7.info('WebRTC enable ringing');
10000
+ logger$5.info('WebRTC enable ringing');
9931
10001
  this.ringingEnabled = true;
9932
10002
  }
9933
10003
 
9934
10004
  disableRinging() {
9935
- logger$7.info('WebRTC disable ringing');
10005
+ logger$5.info('WebRTC disable ringing');
9936
10006
  this.ringingEnabled = false;
9937
10007
  }
9938
10008
 
@@ -9972,7 +10042,7 @@ class WebRTCPhone extends Emitter {
9972
10042
 
9973
10043
  // Deprecated
9974
10044
  getLocalMediaStream(callSession ) {
9975
- logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10045
+ logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9976
10046
  return this.getLocalStream(callSession);
9977
10047
  }
9978
10048
 
@@ -9992,6 +10062,10 @@ class WebRTCPhone extends Emitter {
9992
10062
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9993
10063
  }
9994
10064
 
10065
+ getRemoteVideoStreamFromPc(callSession ) {
10066
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10067
+ }
10068
+
9995
10069
  hasRemoteVideo(callSession ) {
9996
10070
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9997
10071
  }
@@ -10010,7 +10084,7 @@ class WebRTCPhone extends Emitter {
10010
10084
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10011
10085
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10012
10086
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10013
- logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10087
+ logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10014
10088
 
10015
10089
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10016
10090
  this.incomingSessions.push(callSession.getId());
@@ -10033,7 +10107,7 @@ class WebRTCPhone extends Emitter {
10033
10107
  });
10034
10108
 
10035
10109
  this.client.on(this.client.ON_REINVITE, (...args) => {
10036
- logger$7.info('WebRTC on reinvite', {
10110
+ logger$5.info('WebRTC on reinvite', {
10037
10111
  sessionId: args[0].id,
10038
10112
  inviteId: args[1].id,
10039
10113
  updatedCalleeName: args[2],
@@ -10053,7 +10127,7 @@ class WebRTCPhone extends Emitter {
10053
10127
  });
10054
10128
 
10055
10129
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10056
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10130
+ logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10057
10131
 
10058
10132
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10059
10133
 
@@ -10064,22 +10138,22 @@ class WebRTCPhone extends Emitter {
10064
10138
  this.client.on('ended', () => {});
10065
10139
 
10066
10140
  this.client.on(this.client.ON_ERROR, e => {
10067
- logger$7.error('WebRTC error', e);
10141
+ logger$5.error('WebRTC error', e);
10068
10142
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10069
10143
  });
10070
10144
 
10071
10145
  this.client.on(this.client.UNREGISTERED, () => {
10072
- logger$7.info('WebRTC unregistered');
10146
+ logger$5.info('WebRTC unregistered');
10073
10147
  this.eventEmitter.emit(ON_UNREGISTERED);
10074
10148
  });
10075
10149
 
10076
10150
  this.client.on(this.client.ON_DISCONNECTED, () => {
10077
- logger$7.info('WebRTC disconnected');
10078
- this.eventEmitter.emit(ON_DISCONNECTED);
10151
+ logger$5.info('WebRTC disconnected');
10152
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
10079
10153
  });
10080
10154
 
10081
10155
  this.client.on(this.client.REGISTERED, () => {
10082
- logger$7.info('WebRTC registered', {
10156
+ logger$5.info('WebRTC registered', {
10083
10157
  shouldSendReinvite: this.shouldSendReinvite,
10084
10158
  state: this.currentSipSession ? this.currentSipSession.state : null,
10085
10159
  currentSipSession: !!this.currentSipSession,
@@ -10092,23 +10166,27 @@ class WebRTCPhone extends Emitter {
10092
10166
  if (this.shouldSendReinvite && this.currentSipSession
10093
10167
  && this.currentSipSession.state === sessionState.SessionState.Established) {
10094
10168
  this.shouldSendReinvite = false;
10169
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
10170
+ const isConference = pc ? pc.sfu : false;
10171
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
10172
+
10095
10173
  try {
10096
10174
  // Send reinvite with iceRestart
10097
- this.sendReinvite(this.currentCallSession, null, false, false, true);
10175
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10098
10176
  } catch (e) {
10099
- logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10177
+ logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10100
10178
  }
10101
10179
  }
10102
10180
  });
10103
10181
 
10104
10182
  this.client.on(this.client.CONNECTED, () => {
10105
- logger$7.info('WebRTC client connected');
10183
+ logger$5.info('WebRTC client connected');
10106
10184
 
10107
10185
  this.stopHeartbeat();
10108
10186
  });
10109
10187
 
10110
10188
  this.client.on(this.client.DISCONNECTED, () => {
10111
- logger$7.info('WebRTC client disconnected');
10189
+ logger$5.info('WebRTC client disconnected');
10112
10190
 
10113
10191
  this.eventEmitter.emit(ON_UNREGISTERED);
10114
10192
 
@@ -10122,7 +10200,7 @@ class WebRTCPhone extends Emitter {
10122
10200
  });
10123
10201
 
10124
10202
  this.client.on(this.client.ON_TRACK, (session, event) => {
10125
- this.eventEmitter.emit(ON_TRACK, session, event);
10203
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
10126
10204
  });
10127
10205
 
10128
10206
  this.client.on('onVideoInputChange', stream => {
@@ -10137,7 +10215,7 @@ class WebRTCPhone extends Emitter {
10137
10215
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10138
10216
  const callSession = this.getCallSession(this.getSipSessionId(session));
10139
10217
 
10140
- this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10218
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10141
10219
  });
10142
10220
 
10143
10221
  // Used when upgrading directly in screenshare mode
@@ -10146,7 +10224,7 @@ class WebRTCPhone extends Emitter {
10146
10224
  const localStream = this.client.getLocalStream(sipSessionId);
10147
10225
  const callSession = this.callSessions[sipSessionId];
10148
10226
 
10149
- logger$7.info('Updrading directly in screensharing mode', {
10227
+ logger$5.info('Updrading directly in screensharing mode', {
10150
10228
  sipSessionId,
10151
10229
  tracks: localStream ? localStream.getTracks() : null,
10152
10230
  });
@@ -10178,6 +10256,15 @@ class WebRTCPhone extends Emitter {
10178
10256
  return this.client.getSipSessionId(sipSession);
10179
10257
  }
10180
10258
 
10259
+ _updateCallSession(callSession ) {
10260
+ const sipSession = this.findSipSession(callSession);
10261
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10262
+
10263
+ if (sipSessionId) {
10264
+ this.callSessions[sipSessionId] = callSession;
10265
+ }
10266
+ }
10267
+
10181
10268
  _onMessage(message ) {
10182
10269
  if (!message || message.method !== 'MESSAGE') {
10183
10270
  return;
@@ -10315,8 +10402,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10315
10402
  ON_CALL_ENDED: ON_CALL_ENDED,
10316
10403
  ON_CALL_ENDING: ON_CALL_ENDING,
10317
10404
  ON_MESSAGE: ON_MESSAGE,
10318
- ON_REINVITE: ON_REINVITE,
10319
- ON_TRACK: ON_TRACK,
10405
+ ON_REINVITE: ON_REINVITE$1,
10406
+ ON_TRACK: ON_TRACK$1,
10320
10407
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10321
10408
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10322
10409
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10331,13 +10418,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10331
10418
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10332
10419
  ON_CALL_ERROR: ON_CALL_ERROR,
10333
10420
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10334
- ON_NETWORK_STATS: ON_NETWORK_STATS,
10421
+ ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10335
10422
  ON_CHAT: ON_CHAT,
10336
10423
  ON_SIGNAL: ON_SIGNAL,
10337
- ON_DISCONNECTED: ON_DISCONNECTED,
10424
+ ON_DISCONNECTED: ON_DISCONNECTED$1,
10338
10425
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10339
10426
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10340
- events: events,
10427
+ events: events$1,
10341
10428
  'default': WebRTCPhone
10342
10429
  });
10343
10430
 
@@ -10675,6 +10762,11 @@ class Phone extends Emitter {
10675
10762
  return this.getRemoteVideoStream(callSession);
10676
10763
  }
10677
10764
 
10765
+ // Useful in a react-native environment when remoteMediaStream is not updated
10766
+ getRemoteVideoStreamFromPc(callSession ) {
10767
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10768
+ }
10769
+
10678
10770
  hasVideo(callSession ) {
10679
10771
  return this.phone ? this.phone.hasVideo(callSession) : false;
10680
10772
  }
@@ -10726,7 +10818,7 @@ class Phone extends Emitter {
10726
10818
 
10727
10819
  _transferEvents() {
10728
10820
  this.unbind();
10729
- [...events$1, ...transportEvents].forEach(event => {
10821
+ [...events, ...transportEvents].forEach(event => {
10730
10822
  this.client.on(event, (...args) =>
10731
10823
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10732
10824
  });
@@ -10748,7 +10840,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10748
10840
 
10749
10841
  //
10750
10842
 
10751
- const SOCKET_EVENTS$1 = {
10843
+ const SOCKET_EVENTS = {
10752
10844
  ON_OPEN: 'onopen',
10753
10845
  ON_MESSAGE: 'onmessage',
10754
10846
  ON_ERROR: 'onerror',
@@ -10834,6 +10926,7 @@ const AGENT_PAUSED = 'agent_paused';
10834
10926
  const AGENT_UNPAUSED = 'agent_unpaused';
10835
10927
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10836
10928
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10929
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10837
10930
 
10838
10931
  const BLACKLIST_EVENTS = [
10839
10932
  CHAT_MESSAGE_SENT,
@@ -10843,7 +10936,7 @@ const BLACKLIST_EVENTS = [
10843
10936
  ];
10844
10937
 
10845
10938
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10846
- const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10939
+ const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
10847
10940
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10848
10941
 
10849
10942
  class WebSocketClient extends Emitter {
@@ -10892,24 +10985,24 @@ class WebSocketClient extends Emitter {
10892
10985
  }
10893
10986
 
10894
10987
  connect() {
10895
- logger$5.info('connect method started', { host: this.host, token: this.token });
10988
+ logger$7.info('connect method started', { host: this.host, token: this.token });
10896
10989
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
10897
10990
  if (this.options.binaryType) {
10898
10991
  this.socket.binaryType = this.options.binaryType;
10899
10992
  }
10900
10993
 
10901
10994
  this.socket.onopen = () => {
10902
- logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
10903
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10995
+ logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
10996
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10904
10997
  };
10905
10998
 
10906
10999
  this.socket.onerror = event => {
10907
- logger$5.error('on Wazo WS error', event.target);
10908
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
11000
+ logger$7.error('on Wazo WS error', event.target);
11001
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10909
11002
  };
10910
11003
 
10911
11004
  this.socket.onmessage = (event ) => {
10912
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
11005
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10913
11006
 
10914
11007
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10915
11008
  let { name } = message;
@@ -10934,7 +11027,7 @@ class WebSocketClient extends Emitter {
10934
11027
 
10935
11028
  this.socket.onclose = event => {
10936
11029
  // Can't be converted to JSON (circular structure)
10937
- logger$5.info('on Wazo WS close', {
11030
+ logger$7.info('on Wazo WS close', {
10938
11031
  reason: event.reason,
10939
11032
  code: event.code,
10940
11033
  readyState: event.target.readyState,
@@ -10942,22 +11035,22 @@ class WebSocketClient extends Emitter {
10942
11035
  token: this.token,
10943
11036
  });
10944
11037
  this.initialized = false;
10945
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
11038
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10946
11039
 
10947
11040
  switch (event.code) {
10948
11041
  case 4002:
10949
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
11042
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10950
11043
  break;
10951
11044
  }
10952
11045
  };
10953
11046
 
10954
11047
  this.socket.onerror = event => {
10955
- logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11048
+ logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
10956
11049
  };
10957
11050
  }
10958
11051
 
10959
11052
  close(force = false) {
10960
- logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11053
+ logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
10961
11054
 
10962
11055
  if (!this.socket) {
10963
11056
  return;
@@ -10975,7 +11068,7 @@ class WebSocketClient extends Emitter {
10975
11068
 
10976
11069
  updateToken(token ) {
10977
11070
  this.token = token;
10978
- logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11071
+ logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
10979
11072
 
10980
11073
  if (this.socket) {
10981
11074
  // If still connected, send the token to the WS
@@ -10993,7 +11086,7 @@ class WebSocketClient extends Emitter {
10993
11086
  }
10994
11087
 
10995
11088
  startHeartbeat() {
10996
- logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11089
+ logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
10997
11090
 
10998
11091
  if (!this.socket) {
10999
11092
  this.heartbeat.stop();
@@ -11007,7 +11100,7 @@ class WebSocketClient extends Emitter {
11007
11100
  }
11008
11101
 
11009
11102
  stopHeartbeat() {
11010
- logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11103
+ logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11011
11104
 
11012
11105
  this.heartbeat.stop();
11013
11106
  }
@@ -11037,7 +11130,7 @@ class WebSocketClient extends Emitter {
11037
11130
  }
11038
11131
 
11039
11132
  reconnect(reason ) {
11040
- logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11133
+ logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11041
11134
  if (!this.socket) {
11042
11135
  return;
11043
11136
  }
@@ -11062,7 +11155,7 @@ class WebSocketClient extends Emitter {
11062
11155
  break;
11063
11156
  case 'start':
11064
11157
  this.initialized = true;
11065
- this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
11158
+ this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
11066
11159
  break;
11067
11160
  default:
11068
11161
  this.eventEmitter.emit('message', message);
@@ -11093,7 +11186,7 @@ class WebSocketClient extends Emitter {
11093
11186
  this.close();
11094
11187
  }
11095
11188
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11096
- logger$5.log('Wazo WS url computed to reconnect', { url });
11189
+ logger$7.log('Wazo WS url computed to reconnect', { url });
11097
11190
 
11098
11191
  return url;
11099
11192
  }
@@ -11101,15 +11194,15 @@ class WebSocketClient extends Emitter {
11101
11194
  _onHeartbeat(message ) {
11102
11195
  if (message.payload === 'pong') {
11103
11196
  this.heartbeat.onHeartbeat();
11104
- logger$5.log('on heartbeat received from Wazo WS');
11197
+ logger$7.log('on heartbeat received from Wazo WS');
11105
11198
  }
11106
11199
  }
11107
11200
 
11108
11201
  async _onHeartbeatTimeout() {
11109
- logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
11202
+ logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
11110
11203
 
11111
11204
  this.close();
11112
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
11205
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
11113
11206
 
11114
11207
  if (this.onHeartBeatTimeout) {
11115
11208
  this.onHeartBeatTimeout();
@@ -11184,11 +11277,12 @@ WebSocketClient.eventLists = [
11184
11277
  AGENT_UNPAUSED,
11185
11278
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11186
11279
  CONFERENCE_ADHOC_DELETED,
11280
+ MEETING_USER_PROGRESS,
11187
11281
  ];
11188
11282
 
11189
11283
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11190
11284
  __proto__: null,
11191
- SOCKET_EVENTS: SOCKET_EVENTS$1,
11285
+ SOCKET_EVENTS: SOCKET_EVENTS,
11192
11286
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11193
11287
  FAVORITE_ADDED: FAVORITE_ADDED,
11194
11288
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11254,16 +11348,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11254
11348
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11255
11349
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11256
11350
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11351
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11257
11352
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11258
11353
  'default': WebSocketClient
11259
11354
  });
11260
11355
 
11261
11356
  //
11262
11357
 
11263
- const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11264
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11358
+ const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11359
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11265
11360
 
11266
- const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
11361
+ const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
11267
11362
 
11268
11363
  class Websocket extends Emitter {
11269
11364
 
@@ -11277,9 +11372,9 @@ class Websocket extends Emitter {
11277
11372
  // $FlowFixMe
11278
11373
  this[key] = OTHER_EVENTS[key];
11279
11374
  });
11280
- Object.keys(SOCKET_EVENTS).forEach(key => {
11375
+ Object.keys(SOCKET_EVENTS$1).forEach(key => {
11281
11376
  // $FlowFixMe
11282
- this[key] = SOCKET_EVENTS[key];
11377
+ this[key] = SOCKET_EVENTS$1[key];
11283
11378
  });
11284
11379
  this.eventLists = WebSocketClient.eventLists;
11285
11380
 
@@ -11287,7 +11382,7 @@ class Websocket extends Emitter {
11287
11382
  }
11288
11383
 
11289
11384
  open(host , session ) {
11290
- logger$4.info('open simple WebSocket', { host, token: session.token });
11385
+ logger$8.info('open simple WebSocket', { host, token: session.token });
11291
11386
  this.ws = new WebSocketClient(
11292
11387
  {
11293
11388
  host,
@@ -11315,7 +11410,7 @@ class Websocket extends Emitter {
11315
11410
  }
11316
11411
 
11317
11412
  updateToken(token ) {
11318
- logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
11413
+ logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
11319
11414
 
11320
11415
  if (!this.ws) {
11321
11416
  return;
@@ -11343,12 +11438,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
11343
11438
 
11344
11439
  //
11345
11440
 
11346
- const logger$3 = IssueReporter$1.loggerFor('sdk-sip-room');
11441
+ const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
11347
11442
 
11348
- class SipRoom extends Room {
11443
+ class SipRoom extends Room$1 {
11349
11444
 
11350
11445
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
11351
- logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11446
+ logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
11352
11447
 
11353
11448
  if (!room) {
11354
11449
  await Wazo.Phone.connect();
@@ -11364,7 +11459,7 @@ class SipRoom extends Room {
11364
11459
  room.setCallId(room.callSession.call.id);
11365
11460
  }
11366
11461
 
11367
- logger$3.info('connected to room', {
11462
+ logger$9.info('connected to room', {
11368
11463
  extension: room.extension,
11369
11464
  });
11370
11465
 
@@ -11372,7 +11467,7 @@ class SipRoom extends Room {
11372
11467
  }
11373
11468
 
11374
11469
  mute() {
11375
- logger$3.info('mute sip room');
11470
+ logger$9.info('mute sip room');
11376
11471
 
11377
11472
  Wazo.Phone.mute(this.callSession, false);
11378
11473
 
@@ -11380,7 +11475,7 @@ class SipRoom extends Room {
11380
11475
  }
11381
11476
 
11382
11477
  unmute() {
11383
- logger$3.info('unmute sip room');
11478
+ logger$9.info('unmute sip room');
11384
11479
 
11385
11480
  Wazo.Phone.unmute(this.callSession, false);
11386
11481
 
@@ -11482,7 +11577,7 @@ class SipRoom extends Room {
11482
11577
 
11483
11578
  //
11484
11579
 
11485
- const logger$2 = IssueReporter$1.loggerFor('room');
11580
+ const logger$a = IssueReporter$1.loggerFor('room');
11486
11581
 
11487
11582
  class Participant extends Emitter {
11488
11583
 
@@ -11604,7 +11699,7 @@ class Participant extends Emitter {
11604
11699
  }
11605
11700
 
11606
11701
  onTalking(isTalking ) {
11607
- logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11702
+ logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11608
11703
  this.isTalking = isTalking;
11609
11704
  // you may notice we're not broadcasting: since all participants are getting this info
11610
11705
  // directly from asterisk, there's no need to do so
@@ -11707,7 +11802,7 @@ class Participant extends Emitter {
11707
11802
  }
11708
11803
 
11709
11804
  updateStatus(status , broadcast = true) {
11710
- logger$2.info('updating participant status', { name: this.name, status });
11805
+ logger$a.info('updating participant status', { name: this.name, status });
11711
11806
 
11712
11807
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11713
11808
  if (status.audioMuted) {
@@ -11755,7 +11850,7 @@ class Participant extends Emitter {
11755
11850
 
11756
11851
  broadcastStatus(inboundStatus = null) {
11757
11852
  const status = inboundStatus || this.getStatus();
11758
- logger$2.info('broadcasting participant status', { callId: this.callId, status });
11853
+ logger$a.info('broadcasting participant status', { callId: this.callId, status });
11759
11854
 
11760
11855
  this.room.sendSignal({
11761
11856
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11959,7 +12054,7 @@ class NotificationOptions {
11959
12054
 
11960
12055
 
11961
12056
  // Represents a conference room, like `9000`.
11962
- class Room$1 {
12057
+ class Room {
11963
12058
 
11964
12059
 
11965
12060
 
@@ -11980,7 +12075,7 @@ class Room$1 {
11980
12075
  }
11981
12076
 
11982
12077
  connect(callSession ) {
11983
- return new Room$1({ ...this, connectedCallSession: callSession });
12078
+ return new Room({ ...this, connectedCallSession: callSession });
11984
12079
  }
11985
12080
 
11986
12081
  has(callSession ) {
@@ -11989,7 +12084,7 @@ class Room$1 {
11989
12084
 
11990
12085
  addParticipant(uuid , extension , talking = null) {
11991
12086
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
11992
- return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12087
+ return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
11993
12088
  }
11994
12089
 
11995
12090
  return this;
@@ -12008,7 +12103,7 @@ class Room$1 {
12008
12103
  updatedParticipants.push(participant);
12009
12104
  }
12010
12105
 
12011
- return new Room$1({ ...this, participants: updatedParticipants });
12106
+ return new Room({ ...this, participants: updatedParticipants });
12012
12107
  }
12013
12108
 
12014
12109
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12024,7 +12119,7 @@ class Room$1 {
12024
12119
  updatedParticipants.push(participant);
12025
12120
  }
12026
12121
 
12027
- return new Room$1({ ...this, participants: updatedParticipants });
12122
+ return new Room({ ...this, participants: updatedParticipants });
12028
12123
  }
12029
12124
 
12030
12125
  hasCallWithId(id ) {
@@ -12032,18 +12127,18 @@ class Room$1 {
12032
12127
  }
12033
12128
 
12034
12129
  disconnect() {
12035
- return new Room$1({ ...this, connectedCallSession: null });
12130
+ return new Room({ ...this, connectedCallSession: null });
12036
12131
  }
12037
12132
 
12038
12133
  removeParticipantWithUUID(uuid ) {
12039
- return new Room$1({
12134
+ return new Room({
12040
12135
  ...this,
12041
12136
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12042
12137
  });
12043
12138
  }
12044
12139
 
12045
12140
  removeParticipantWithExtension(extension ) {
12046
- return new Room$1({
12141
+ return new Room({
12047
12142
  ...this,
12048
12143
  participants: this.participants.filter(participant => participant.extension !== extension),
12049
12144
  });
@@ -12054,7 +12149,7 @@ class Room$1 {
12054
12149
  }
12055
12150
 
12056
12151
  static newFrom(room ) {
12057
- return newFrom(room, Room$1);
12152
+ return newFrom(room, Room);
12058
12153
  }
12059
12154
  }
12060
12155
 
@@ -12361,11 +12456,11 @@ var wazoWebsocket = {
12361
12456
  resolve();
12362
12457
  };
12363
12458
 
12364
- client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
12459
+ client.on(SOCKET_EVENTS.ON_ERROR, error => {
12365
12460
  handleError(`Connection error : ${error}`);
12366
12461
  });
12367
12462
 
12368
- client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
12463
+ client.on(SOCKET_EVENTS.ON_OPEN, () => {
12369
12464
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12370
12465
  client.setOnHeartbeatTimeout(() => {
12371
12466
  handleError('No response to heartbeat');
@@ -12466,7 +12561,7 @@ var webrtc = {
12466
12561
  }),
12467
12562
  };
12468
12563
 
12469
- const parseCandidate = line => {
12564
+ const parseCandidate$1 = line => {
12470
12565
  let parts;
12471
12566
  // Parse both variants.
12472
12567
  if (line.indexOf('a=candidate:') === 0) {
@@ -12557,7 +12652,7 @@ var SymmetricNat = {
12557
12652
  }
12558
12653
 
12559
12654
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
12560
- const cand = parseCandidate(e.candidate.candidate);
12655
+ const cand = parseCandidate$1(e.candidate.candidate);
12561
12656
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
12562
12657
  candidates[cand.relatedPort].push(cand.port);
12563
12658
  } else if (!e.candidate) {
@@ -12625,7 +12720,7 @@ var iceIpv4 = {
12625
12720
  const rawCandidate = e.candidate.candidate;
12626
12721
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
12627
12722
  hasSrflxOrRelay = true;
12628
- const candidate = parseCandidate(e.candidate.candidate);
12723
+ const candidate = parseCandidate$1(e.candidate.candidate);
12629
12724
  ips.push(candidate.ip);
12630
12725
  }
12631
12726
  } else if (!e.candidate) {
@@ -12662,7 +12757,7 @@ var checks = [
12662
12757
 
12663
12758
  //
12664
12759
 
12665
- const logger$1 = IssueReporter$1.loggerFor('engine-check');
12760
+ const logger$b = IssueReporter$1.loggerFor('engine-check');
12666
12761
 
12667
12762
  class Checker {
12668
12763
 
@@ -12680,28 +12775,28 @@ class Checker {
12680
12775
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
12681
12776
  await this._addEngineVersion();
12682
12777
 
12683
- logger$1.info('Engine check starting');
12778
+ logger$b.info('Engine check starting');
12684
12779
 
12685
12780
  for (let i = 0; i < this.checks.length; i++) {
12686
12781
  const { name, check } = this.checks[i];
12687
12782
 
12688
- logger$1.info(`Checking ${name} ...`);
12783
+ logger$b.info(`Checking ${name} ...`);
12689
12784
 
12690
12785
  onCheckBegin(name);
12691
12786
  try {
12692
12787
  // eslint-disable-next-line no-await-in-loop
12693
12788
  const result = await check(this.server, this.session, this.externalAppConfig);
12694
- logger$1.info(`Checking ${name} success.`, { result });
12789
+ logger$b.info(`Checking ${name} success.`, { result });
12695
12790
 
12696
12791
  onCheckResult(name, result);
12697
12792
  } catch (e) {
12698
- logger$1.info(`Checking ${name} failure`, { message: e.message });
12793
+ logger$b.info(`Checking ${name} failure`, { message: e.message });
12699
12794
 
12700
12795
  onCheckResult(name, e);
12701
12796
  }
12702
12797
  }
12703
12798
 
12704
- logger$1.info('Engine check done.');
12799
+ logger$b.info('Engine check done.');
12705
12800
  }
12706
12801
 
12707
12802
  addCheck(check ) {
@@ -12725,7 +12820,7 @@ const Wazo = {
12725
12820
  Auth: Auth$1,
12726
12821
  Phone: Phone$1,
12727
12822
  Websocket: Websocket$1,
12728
- Room,
12823
+ Room: Room$1,
12729
12824
  SipRoom,
12730
12825
  RemoteParticipant,
12731
12826
  LocalParticipant,
@@ -12758,7 +12853,7 @@ const Wazo = {
12758
12853
  Session,
12759
12854
  Voicemail,
12760
12855
  Relocation,
12761
- ConferenceRoom: Room$1,
12856
+ ConferenceRoom: Room,
12762
12857
  CallSession,
12763
12858
  IndirectTransfer,
12764
12859
  SwitchboardCall,
@@ -12797,9 +12892,9 @@ if (global) {
12797
12892
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12798
12893
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12799
12894
 
12800
- const logger = IssueReporter$1.loggerFor('sdk-room');
12895
+ const logger$c = IssueReporter$1.loggerFor('sdk-room');
12801
12896
 
12802
- class Room extends Emitter {
12897
+ class Room$1 extends Emitter {
12803
12898
 
12804
12899
 
12805
12900
 
@@ -12857,7 +12952,7 @@ class Room extends Emitter {
12857
12952
  extra = {},
12858
12953
  ) {
12859
12954
  super();
12860
- logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
12955
+ logger$c.info('room initialized', { callId, extension, sourceId, meetingUuid });
12861
12956
 
12862
12957
  // Represents the room callSession
12863
12958
  this.callSession = callSession;
@@ -12923,7 +13018,7 @@ class Room extends Emitter {
12923
13018
  * @returns {Promise<Room>}
12924
13019
  */
12925
13020
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
12926
- logger.info('connecting to room', { extension, audioOnly, room: !!room });
13021
+ logger$c.info('connecting to room', { extension, audioOnly, room: !!room });
12927
13022
 
12928
13023
  if (!room) {
12929
13024
  await Wazo.Phone.connect();
@@ -12936,7 +13031,7 @@ class Room extends Emitter {
12936
13031
 
12937
13032
  // Call_created is triggered before call_accepted, so we have to listen for it here.
12938
13033
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
12939
- logger.info('room call received via WS', { callId: data.call_id });
13034
+ logger$c.info('room call received via WS', { callId: data.call_id });
12940
13035
  if (room) {
12941
13036
  room.setCallId(data.call_id);
12942
13037
  }
@@ -12944,7 +13039,7 @@ class Room extends Emitter {
12944
13039
 
12945
13040
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
12946
13041
  // eslint-disable-next-line no-param-reassign
12947
- room = new Room(callSession, extension, null, null, extra);
13042
+ room = new Room$1(callSession, extension, null, null, extra);
12948
13043
 
12949
13044
  // Wait for the call to be accepted
12950
13045
  await new Promise((resolve, reject) => {
@@ -12965,7 +13060,7 @@ class Room extends Emitter {
12965
13060
  // Retrieve conference
12966
13061
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
12967
13062
 
12968
- logger.info('connected to room', {
13063
+ logger$c.info('connected to room', {
12969
13064
  sourceId: conference ? conference.sourceId : null,
12970
13065
  name: conference ? conference.name : null,
12971
13066
  });
@@ -12975,7 +13070,7 @@ class Room extends Emitter {
12975
13070
  room.setName(conference.name);
12976
13071
  }
12977
13072
  } else if (meeting) {
12978
- logger.info('Already connected to meeting', {
13073
+ logger$c.info('Already connected to meeting', {
12979
13074
  uuid: meeting.uuid,
12980
13075
  name: meeting.name,
12981
13076
  });
@@ -12988,13 +13083,13 @@ class Room extends Emitter {
12988
13083
  }
12989
13084
 
12990
13085
  static disconnect() {
12991
- logger.info('static disconnection to room');
13086
+ logger$c.info('static disconnection to room');
12992
13087
 
12993
13088
  Wazo.Phone.disconnect();
12994
13089
  }
12995
13090
 
12996
13091
  async disconnect() {
12997
- logger.info('disconnection to room called');
13092
+ logger$c.info('disconnection to room called');
12998
13093
 
12999
13094
  await Wazo.Phone.hangup(this.callSession);
13000
13095
  this.callSession = null;
@@ -13014,19 +13109,19 @@ class Room extends Emitter {
13014
13109
  }
13015
13110
 
13016
13111
  setSourceId(sourceId ) {
13017
- logger.info('set room source id', { sourceId });
13112
+ logger$c.info('set room source id', { sourceId });
13018
13113
 
13019
13114
  this.sourceId = sourceId;
13020
13115
  }
13021
13116
 
13022
13117
  setMeetingUuid(meetingUuid ) {
13023
- logger.info('set meeting uuid', { meetingUuid });
13118
+ logger$c.info('set meeting uuid', { meetingUuid });
13024
13119
 
13025
13120
  this.meetingUuid = meetingUuid;
13026
13121
  }
13027
13122
 
13028
13123
  setCallId(callId ) {
13029
- logger.info('set room call id', { callId });
13124
+ logger$c.info('set room call id', { callId });
13030
13125
 
13031
13126
  if (callId) {
13032
13127
  this.callId = callId;
@@ -13034,7 +13129,7 @@ class Room extends Emitter {
13034
13129
  }
13035
13130
 
13036
13131
  setName(name ) {
13037
- logger.info('set room name', { name });
13132
+ logger$c.info('set room name', { name });
13038
13133
 
13039
13134
  this.name = name;
13040
13135
  }
@@ -13053,7 +13148,7 @@ class Room extends Emitter {
13053
13148
  }
13054
13149
 
13055
13150
  async startScreenSharing(constraints ) {
13056
- logger.info('start room screen sharing', { constraints });
13151
+ logger$c.info('start room screen sharing', { constraints });
13057
13152
 
13058
13153
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
13059
13154
  if (!screensharingStream) {
@@ -13067,7 +13162,7 @@ class Room extends Emitter {
13067
13162
  }
13068
13163
 
13069
13164
  async stopScreenSharing(restoreLocalStream = true) {
13070
- logger.info('stop room screen sharing');
13165
+ logger$c.info('stop room screen sharing');
13071
13166
 
13072
13167
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
13073
13168
 
@@ -13079,7 +13174,7 @@ class Room extends Emitter {
13079
13174
  }
13080
13175
 
13081
13176
  turnCameraOff() {
13082
- logger.info('turn room camera off');
13177
+ logger$c.info('turn room camera off');
13083
13178
 
13084
13179
  Wazo.Phone.turnCameraOff(this.callSession);
13085
13180
 
@@ -13089,7 +13184,7 @@ class Room extends Emitter {
13089
13184
  }
13090
13185
 
13091
13186
  turnCameraOn() {
13092
- logger.info('turn room camera on');
13187
+ logger$c.info('turn room camera on');
13093
13188
 
13094
13189
  Wazo.Phone.turnCameraOn(this.callSession);
13095
13190
 
@@ -13099,7 +13194,7 @@ class Room extends Emitter {
13099
13194
  }
13100
13195
 
13101
13196
  mute() {
13102
- logger.info('mute room');
13197
+ logger$c.info('mute room');
13103
13198
 
13104
13199
  Wazo.Phone.mute(this.callSession);
13105
13200
 
@@ -13107,7 +13202,7 @@ class Room extends Emitter {
13107
13202
  }
13108
13203
 
13109
13204
  unmute() {
13110
- logger.info('unmute room');
13205
+ logger$c.info('unmute room');
13111
13206
 
13112
13207
  Wazo.Phone.unmute(this.callSession);
13113
13208
 
@@ -13127,7 +13222,7 @@ class Room extends Emitter {
13127
13222
  }
13128
13223
 
13129
13224
  hold() {
13130
- logger.info('hold room');
13225
+ logger$c.info('hold room');
13131
13226
 
13132
13227
  Wazo.Phone.hold(this.callSession, true);
13133
13228
 
@@ -13137,7 +13232,7 @@ class Room extends Emitter {
13137
13232
  }
13138
13233
 
13139
13234
  async resume() {
13140
- logger.info('resume room');
13235
+ logger$c.info('resume room');
13141
13236
 
13142
13237
  const newStream = await Wazo.Phone.resume(this.callSession, true);
13143
13238
 
@@ -13165,13 +13260,13 @@ class Room extends Emitter {
13165
13260
  }
13166
13261
 
13167
13262
  sendDTMF(tone ) {
13168
- logger.info('send room DTMF', { tone });
13263
+ logger$c.info('send room DTMF', { tone });
13169
13264
 
13170
13265
  Wazo.Phone.sendDTMF(tone, this.callSession);
13171
13266
  }
13172
13267
 
13173
13268
  async sendReinvite(newConstraints = null) {
13174
- logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13269
+ logger$c.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13175
13270
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
13176
13271
 
13177
13272
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13230,7 +13325,7 @@ class Room extends Emitter {
13230
13325
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13231
13326
 
13232
13327
  this.on(this.ON_AUDIO_STREAM, stream => {
13233
- logger.info('on room audio stream');
13328
+ logger$c.info('on room audio stream');
13234
13329
 
13235
13330
  this.audioStream = stream;
13236
13331
  if (!this.roomAudioElement) {
@@ -13243,7 +13338,7 @@ class Room extends Emitter {
13243
13338
  });
13244
13339
 
13245
13340
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13246
- logger.info('on room video stream', { streamId });
13341
+ logger$c.info('on room video stream', { streamId });
13247
13342
 
13248
13343
  this._mapMsid(sipSession.body.body);
13249
13344
 
@@ -13258,7 +13353,7 @@ class Room extends Emitter {
13258
13353
  });
13259
13354
 
13260
13355
  this.on(this.ON_REMOVE_STREAM, stream => {
13261
- logger.info('on room remove stream');
13356
+ logger$c.info('on room remove stream');
13262
13357
 
13263
13358
  const participant = this.participants.find(someParticipant =>
13264
13359
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13390,7 +13485,7 @@ class Room extends Emitter {
13390
13485
  const requester = this._getParticipantFromCallId(origin.callId);
13391
13486
  if (requester) {
13392
13487
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13393
- logger.info('trigger room requester status', { origin });
13488
+ logger$c.info('trigger room requester status', { origin });
13394
13489
  requester.triggerUpdate('REQUESTER_UPDATE');
13395
13490
  }
13396
13491
  break;
@@ -13421,24 +13516,24 @@ class Room extends Emitter {
13421
13516
 
13422
13517
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13423
13518
  if (participant.user_uuid === session.uuid) {
13424
- logger.info('room current user joined');
13519
+ logger$c.info('room current user joined');
13425
13520
 
13426
13521
  // Retrieve participants via an API calls
13427
13522
  const conferenceId = this.sourceId || payload.data.conference_id;
13428
13523
  let response;
13429
13524
  try {
13430
13525
  if (this.meetingUuid) {
13431
- logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13526
+ logger$c.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13432
13527
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13433
13528
  } else {
13434
- logger.info('fetching conference participants', { conferenceId });
13529
+ logger$c.info('fetching conference participants', { conferenceId });
13435
13530
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13436
13531
  }
13437
13532
  } catch (e) {
13438
- logger.error('room participants fetching, error', e);
13533
+ logger$c.error('room participants fetching, error', e);
13439
13534
  }
13440
13535
  if (response) {
13441
- logger.info('conference participants fetched', { nb: response.items.length });
13536
+ logger$c.info('conference participants fetched', { nb: response.items.length });
13442
13537
  participants = response.items.map(item => {
13443
13538
  const isMe = item.call_id === this.callId;
13444
13539
 
@@ -13465,7 +13560,7 @@ class Room extends Emitter {
13465
13560
  ? new Wazo.RemoteParticipant(this, participant)
13466
13561
  : null;
13467
13562
 
13468
- logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13563
+ logger$c.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13469
13564
 
13470
13565
  if (remoteParticipant) {
13471
13566
  this.participants.push(remoteParticipant);