@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
@@ -873,6 +873,9 @@ class Contact {
873
873
  }
874
874
 
875
875
  static parseMany(response ) {
876
+ if (!response || !response.results) {
877
+ return [];
878
+ }
876
879
  return response.results.map(r => Contact.parse(r, response.column_types));
877
880
  }
878
881
 
@@ -1644,6 +1647,7 @@ class IssueReporter {
1644
1647
 
1645
1648
 
1646
1649
 
1650
+
1647
1651
 
1648
1652
  constructor() {
1649
1653
  addLevelsTo(this);
@@ -1655,12 +1659,17 @@ class IssueReporter {
1655
1659
  this.bufferTimeout = null;
1656
1660
  this._boundProcessBuffer = this._processBuffer.bind(this);
1657
1661
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
1662
+ this._callback = null;
1658
1663
  }
1659
1664
 
1660
1665
  init() {
1661
1666
  this._catchConsole();
1662
1667
  }
1663
1668
 
1669
+ setCallback(cb ) {
1670
+ this._callback = cb;
1671
+ }
1672
+
1664
1673
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
1665
1674
  this.remoteClientConfiguration = configuration;
1666
1675
  }
@@ -1696,6 +1705,7 @@ class IssueReporter {
1696
1705
 
1697
1706
  // Handle category label
1698
1707
  let category = null;
1708
+ let skipSendToRemote = false;
1699
1709
  let extra = {};
1700
1710
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
1701
1711
  category = args[0].split('=')[1];
@@ -1711,6 +1721,7 @@ class IssueReporter {
1711
1721
  errorMessage: lastArg.message,
1712
1722
  errorStack: lastArg.stack,
1713
1723
  errorType: lastArg.constructor.name,
1724
+ skipSendToRemote: lastArg.skipSendToRemote,
1714
1725
  };
1715
1726
  } else {
1716
1727
  extra = lastArg;
@@ -1719,6 +1730,11 @@ class IssueReporter {
1719
1730
  args.splice(1, 1);
1720
1731
  }
1721
1732
 
1733
+ if (extra.skipSendToRemote) {
1734
+ skipSendToRemote = true;
1735
+ delete extra.skipSendToRemote;
1736
+ }
1737
+
1722
1738
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
1723
1739
  const message = args.join(', ');
1724
1740
  let consoleMessage = message;
@@ -1739,7 +1755,13 @@ class IssueReporter {
1739
1755
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
1740
1756
  oldMethod.apply(oldMethod, [date, consoleMessage]);
1741
1757
 
1742
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
1758
+ if (this._callback) {
1759
+ this._callback(level, consoleMessage);
1760
+ }
1761
+
1762
+ if (!skipSendToRemote) {
1763
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
1764
+ }
1743
1765
  }
1744
1766
 
1745
1767
  logRequest(url , options , response , start ) {
@@ -1884,7 +1906,11 @@ class IssueReporter {
1884
1906
  },
1885
1907
  // $FlowFixMe
1886
1908
  body,
1887
- }).catch(() => {
1909
+ }).catch((e ) => {
1910
+ // $FlowFixMe
1911
+ e.skipSendToRemote = true;
1912
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
1913
+
1888
1914
  setTimeout(() => {
1889
1915
  if (isArray) {
1890
1916
  payload = payload.map(message => {
@@ -1931,7 +1957,7 @@ var IssueReporter$1 = new IssueReporter();
1931
1957
 
1932
1958
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1933
1959
 
1934
- const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1960
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1935
1961
 
1936
1962
  // Use a function here to be able to mock it in tests
1937
1963
  const realFetch = () => {
@@ -2070,7 +2096,7 @@ class ApiRequester {
2070
2096
  };
2071
2097
 
2072
2098
  if (this.refreshTokenPromise) {
2073
- logger$c.info('A token is already refreshing, waiting ...', { url });
2099
+ logger.info('A token is already refreshing, waiting ...', { url });
2074
2100
  await this.refreshTokenPromise;
2075
2101
  }
2076
2102
 
@@ -2090,7 +2116,7 @@ class ApiRequester {
2090
2116
  return promise.then(async (err ) => {
2091
2117
  // Check if the token is still valid
2092
2118
  if (firstCall && this._checkTokenExpired(response, err)) {
2093
- logger$c.warn('token expired', { error: err.reason });
2119
+ logger.warn('token expired', { error: err.reason });
2094
2120
  // Replay the call after refreshing the token
2095
2121
  return this._replayWithNewToken(err, path, method, body, headers, parse);
2096
2122
  }
@@ -2100,7 +2126,7 @@ class ApiRequester {
2100
2126
  : exceptionClass.fromResponse(err, response.status);
2101
2127
 
2102
2128
  if (this.shouldLogErrors) {
2103
- logger$c.error('API error', error);
2129
+ logger.error('API error', error);
2104
2130
  }
2105
2131
 
2106
2132
  throw error;
@@ -2110,7 +2136,7 @@ class ApiRequester {
2110
2136
  return newParse(response, isJson);
2111
2137
  }).catch(error => {
2112
2138
  if (this.shouldLogErrors) {
2113
- logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2139
+ logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2114
2140
  }
2115
2141
 
2116
2142
  throw error;
@@ -2138,13 +2164,13 @@ class ApiRequester {
2138
2164
  ) {
2139
2165
  const isTokenNotFound = this._isTokenNotFound(err);
2140
2166
  let newPath = path;
2141
- logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2167
+ logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2142
2168
 
2143
2169
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
2144
2170
 
2145
2171
  return this.refreshTokenPromise.then(() => {
2146
2172
  this.refreshTokenPromise = null;
2147
- logger$c.info('token refreshed', { isTokenNotFound });
2173
+ logger.info('token refreshed', { isTokenNotFound });
2148
2174
  if (isTokenNotFound) {
2149
2175
  const pathParts = path.split('/');
2150
2176
  pathParts.pop();
@@ -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);
@@ -5622,7 +5696,7 @@ class AdHocAPIConference {
5622
5696
 
5623
5697
  /* */
5624
5698
 
5625
- const parseCandidate$1 = (candidate ) => {
5699
+ const parseCandidate = (candidate ) => {
5626
5700
  if (!candidate) {
5627
5701
  return null;
5628
5702
  }
@@ -5635,10 +5709,6 @@ const getSrflxOrRelay = (candidates ) =>
5635
5709
  candidates
5636
5710
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5637
5711
 
5638
- const areCandidateValid = (candidates ) =>
5639
- getSrflxOrRelay(candidates)
5640
- .length > 0;
5641
-
5642
5712
  const getVideoDirection = (sdp ) => {
5643
5713
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5644
5714
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5691,8 +5761,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5691
5761
  /* global RTCSessionDescriptionInit, navigator */
5692
5762
 
5693
5763
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5694
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5695
- const WAIT_FOR_ICE_TIMEOUT = 500;
5696
5764
 
5697
5765
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5698
5766
  const wazoMediaStreamFactory = (constraints ) => {
@@ -5782,7 +5850,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5782
5850
  this.peerConnectionDelegate.onicecandidate = event => {
5783
5851
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5784
5852
  if (event.candidate) {
5785
- this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5853
+ this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5786
5854
  }
5787
5855
  };
5788
5856
 
@@ -5882,38 +5950,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5882
5950
  this._peerConnection = undefined;
5883
5951
  }
5884
5952
 
5885
- async _waitForValidGatheredIce() {
5886
- let tries = 0;
5887
-
5888
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
5889
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
5890
- tries,
5891
- max: MAX_WAIT_FOR_ICE_TRIES,
5892
- });
5893
-
5894
- tries++;
5895
-
5896
- // eslint-disable-next-line no-await-in-loop
5897
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
5898
- }
5899
-
5900
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
5901
- const errorMsg = 'No valid candidates found, can\'t answer the call';
5902
- const error = new Error(errorMsg);
5903
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
5904
-
5905
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
5906
- this.eventEmitter.emit('error', error);
5907
-
5908
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5909
- }
5910
-
5911
- // eslint-disable-next-line
5912
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5913
-
5914
- return this.getLocalSessionDescription();
5915
- }
5916
-
5917
5953
  // Overridden to send `inactive` in conference
5918
5954
  updateDirection(options , isConference = false,
5919
5955
  audioOnly = false) {
@@ -6278,7 +6314,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6278
6314
  const SEND_STATS_DELAY = 5000;
6279
6315
 
6280
6316
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6281
- const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6317
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6282
6318
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6283
6319
 
6284
6320
  // events
@@ -6292,14 +6328,14 @@ const TRANSPORT_ERROR = 'transportError';
6292
6328
  const MESSAGE = 'message';
6293
6329
  const ACCEPTED = 'accepted';
6294
6330
  const REJECTED = 'rejected';
6295
- const ON_TRACK$1 = 'onTrack';
6296
- const ON_REINVITE$1 = 'reinvite';
6331
+ const ON_TRACK = 'onTrack';
6332
+ const ON_REINVITE = 'reinvite';
6297
6333
  const ON_ERROR = 'onError';
6298
6334
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6299
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
6300
- const ON_DISCONNECTED$1 = 'onDisconnected';
6335
+ const ON_NETWORK_STATS = 'onNetworkStats';
6336
+ const ON_DISCONNECTED = 'onDisconnected';
6301
6337
 
6302
- const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6338
+ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6303
6339
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6304
6340
  class CanceledCallError extends Error {}
6305
6341
 
@@ -6435,12 +6471,12 @@ class WebRTCClient extends Emitter {
6435
6471
  this.MESSAGE = MESSAGE;
6436
6472
  this.ACCEPTED = ACCEPTED;
6437
6473
  this.REJECTED = REJECTED;
6438
- this.ON_TRACK = ON_TRACK$1;
6439
- this.ON_REINVITE = ON_REINVITE$1;
6474
+ this.ON_TRACK = ON_TRACK;
6475
+ this.ON_REINVITE = ON_REINVITE;
6440
6476
  this.ON_ERROR = ON_ERROR;
6441
6477
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6442
- this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6443
- this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6478
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6479
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
6444
6480
  }
6445
6481
 
6446
6482
  configureMedia(media ) {
@@ -6457,13 +6493,13 @@ class WebRTCClient extends Emitter {
6457
6493
 
6458
6494
  createUserAgent(configOverrides ) {
6459
6495
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6460
- logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6496
+ logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6461
6497
 
6462
6498
  webRTCConfiguration.delegate = {
6463
6499
  onConnect: this.onConnect.bind(this),
6464
6500
  onDisconnect: this.onDisconnect.bind(this),
6465
6501
  onInvite: (invitation ) => {
6466
- logger$9.info('sdk webrtc on invite', {
6502
+ logger$3.info('sdk webrtc on invite', {
6467
6503
  method: 'delegate.onInvite',
6468
6504
  id: invitation.id,
6469
6505
  remoteURI: invitation.remoteURI,
@@ -6506,7 +6542,7 @@ class WebRTCClient extends Emitter {
6506
6542
  }
6507
6543
 
6508
6544
  onConnect() {
6509
- logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6545
+ logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6510
6546
  this.eventEmitter.emit(CONNECTED);
6511
6547
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6512
6548
  this.registerer.waitingToggle(false);
@@ -6515,7 +6551,7 @@ class WebRTCClient extends Emitter {
6515
6551
  }
6516
6552
 
6517
6553
  async onDisconnect(error ) {
6518
- logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6554
+ logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6519
6555
  this.connectionPromise = null;
6520
6556
  // The UA will attempt to reconnect automatically when an error occurred
6521
6557
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6540,37 +6576,37 @@ class WebRTCClient extends Emitter {
6540
6576
  };
6541
6577
 
6542
6578
  if (this.skipRegister) {
6543
- logger$9.info('sdk webrtc skip register...', logInfo);
6579
+ logger$3.info('sdk webrtc skip register...', logInfo);
6544
6580
  return Promise.resolve();
6545
6581
  }
6546
6582
 
6547
- logger$9.info('sdk webrtc registering...', logInfo);
6583
+ logger$3.info('sdk webrtc registering...', logInfo);
6548
6584
 
6549
6585
  if (!this.userAgent) {
6550
- logger$9.info('sdk webrtc recreating User Agent');
6586
+ logger$3.info('sdk webrtc recreating User Agent');
6551
6587
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6552
6588
  }
6553
6589
  if (!this.userAgent || this.isRegistered()) {
6554
- logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6590
+ logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6555
6591
  return Promise.resolve();
6556
6592
  }
6557
6593
 
6558
6594
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6559
- logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6595
+ logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6560
6596
  return Promise.resolve();
6561
6597
  }
6562
6598
 
6563
6599
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6564
6600
 
6565
6601
  const onRegisterFailed = () => {
6566
- logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6602
+ logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6567
6603
  this.connectionPromise = null;
6568
6604
  if (this.registerer && this.registerer.waiting) {
6569
6605
  this.registerer.waitingToggle(false);
6570
6606
  }
6571
6607
 
6572
6608
  if (tries <= MAX_REGISTER_TRIES) {
6573
- logger$9.info('sdk webrtc registering, retrying...', { tries });
6609
+ logger$3.info('sdk webrtc registering, retrying...', { tries });
6574
6610
  setTimeout(() => this.register(tries + 1), 300);
6575
6611
  }
6576
6612
  };
@@ -6579,18 +6615,18 @@ class WebRTCClient extends Emitter {
6579
6615
  // Avoid race condition with the close method called just before register and setting userAgent to null
6580
6616
  // during the resolution of the primise.
6581
6617
  if (!this.userAgent) {
6582
- logger$9.info('sdk webrtc recreating User Agent after connection');
6618
+ logger$3.info('sdk webrtc recreating User Agent after connection');
6583
6619
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6584
6620
  }
6585
6621
 
6586
- logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6622
+ logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6587
6623
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6588
6624
  this.connectionPromise = null;
6589
6625
  this._monkeyPatchRegisterer(this.registerer);
6590
6626
 
6591
6627
  // Bind registerer events
6592
6628
  this.registerer.stateChange.addListener(newState => {
6593
- logger$9.info('sdk webrtc registering, state changed', { newState });
6629
+ logger$3.info('sdk webrtc registering, state changed', { newState });
6594
6630
 
6595
6631
  if (newState === registererState.RegistererState.Registered && this.registerer
6596
6632
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6603,7 +6639,7 @@ class WebRTCClient extends Emitter {
6603
6639
  const options = {
6604
6640
  requestDelegate: {
6605
6641
  onReject: response => {
6606
- logger$9.error('sdk webrtc registering, rejected', { response });
6642
+ logger$3.error('sdk webrtc registering, rejected', { response });
6607
6643
 
6608
6644
  onRegisterFailed();
6609
6645
  },
@@ -6611,13 +6647,13 @@ class WebRTCClient extends Emitter {
6611
6647
  };
6612
6648
 
6613
6649
  return this.registerer.register(options).catch((e) => {
6614
- logger$9.error('sdk webrtc registering, error', e);
6650
+ logger$3.error('sdk webrtc registering, error', e);
6615
6651
 
6616
6652
  this.eventEmitter.emit(REGISTRATION_FAILED);
6617
6653
  return e;
6618
6654
  });
6619
6655
  }).catch(error => {
6620
- logger$9.error('sdk webrtc registering, transport error', error);
6656
+ logger$3.error('sdk webrtc registering, transport error', error);
6621
6657
  onRegisterFailed();
6622
6658
  });
6623
6659
  }
@@ -6646,21 +6682,21 @@ class WebRTCClient extends Emitter {
6646
6682
  }
6647
6683
 
6648
6684
  unregister() {
6649
- logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6685
+ logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6650
6686
  if (!this.registerer) {
6651
6687
  return Promise.resolve();
6652
6688
  }
6653
6689
 
6654
6690
  try {
6655
6691
  return this.registerer.unregister().then(() => {
6656
- logger$9.info('sdk webrtc unregistered');
6692
+ logger$3.info('sdk webrtc unregistered');
6657
6693
  this._cleanupRegister();
6658
6694
  }).catch(e => {
6659
- logger$9.error('sdk webrtc unregistering, promise error', e);
6695
+ logger$3.error('sdk webrtc unregistering, promise error', e);
6660
6696
  this._cleanupRegister();
6661
6697
  });
6662
6698
  } catch (e) {
6663
- logger$9.error('sdk webrtc unregistering, error', e);
6699
+ logger$3.error('sdk webrtc unregistering, error', e);
6664
6700
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6665
6701
  // error when the registerer is in a bad state
6666
6702
  this._cleanupRegister();
@@ -6668,7 +6704,7 @@ class WebRTCClient extends Emitter {
6668
6704
  }
6669
6705
 
6670
6706
  stop() {
6671
- logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6707
+ logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6672
6708
  if (!this.userAgent) {
6673
6709
  return Promise.resolve();
6674
6710
  }
@@ -6676,12 +6712,12 @@ class WebRTCClient extends Emitter {
6676
6712
  return this.userAgent.stop().then(() => {
6677
6713
  return this._cleanupRegister();
6678
6714
  }).catch(e => {
6679
- logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6715
+ logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6680
6716
  });
6681
6717
  }
6682
6718
 
6683
6719
  call(number , enableVideo , audioOnly = false, conference = false) {
6684
- logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6720
+ logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6685
6721
  const inviterOptions = {
6686
6722
  sessionDescriptionHandlerOptionsReInvite: {
6687
6723
  conference,
@@ -6706,11 +6742,13 @@ class WebRTCClient extends Emitter {
6706
6742
  const inviteOptions = {
6707
6743
  requestDelegate: {
6708
6744
  onAccept: (response ) => {
6709
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6745
+ if (session.sessionDescriptionHandler.peerConnection) {
6746
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6747
+ }
6710
6748
  this._onAccepted(session, response.session, true);
6711
6749
  },
6712
6750
  onReject: (response ) => {
6713
- logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6751
+ logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6714
6752
  this._stopSendingStats(session);
6715
6753
  this.stopNetworkMonitoring(session);
6716
6754
 
@@ -6733,11 +6771,11 @@ class WebRTCClient extends Emitter {
6733
6771
  }
6734
6772
 
6735
6773
  answer(session , enableVideo ) {
6736
- logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6774
+ logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6737
6775
 
6738
6776
  if (!session || !session.accept) {
6739
6777
  const error = 'No session to answer, or not an invitation';
6740
- logger$9.warn(error);
6778
+ logger$3.warn(error);
6741
6779
  return Promise.reject(new Error(error));
6742
6780
  }
6743
6781
  const options = {
@@ -6747,15 +6785,15 @@ class WebRTCClient extends Emitter {
6747
6785
  return session.accept(options).then(() => {
6748
6786
  if (session.isCanceled) {
6749
6787
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6750
- logger$9.error(message, { id: session.id });
6788
+ logger$3.error(message, { id: session.id });
6751
6789
  this.onCallEnded(session);
6752
6790
 
6753
6791
  throw new CanceledCallError(message);
6754
6792
  }
6755
- logger$9.info('sdk webrtc answer, accepted.');
6793
+ logger$3.info('sdk webrtc answer, accepted.');
6756
6794
  this._onAccepted(session);
6757
6795
  }).catch(e => {
6758
- logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6796
+ logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6759
6797
 
6760
6798
  throw e;
6761
6799
  });
@@ -6763,7 +6801,7 @@ class WebRTCClient extends Emitter {
6763
6801
 
6764
6802
  hangup(session ) {
6765
6803
  const { state, id } = session;
6766
- logger$9.info('sdk webrtc hangup call', { id, state });
6804
+ logger$3.info('sdk webrtc hangup call', { id, state });
6767
6805
 
6768
6806
  try {
6769
6807
  this._stopSendingStats(session);
@@ -6792,7 +6830,7 @@ class WebRTCClient extends Emitter {
6792
6830
 
6793
6831
  return bye();
6794
6832
  } catch (error) {
6795
- logger$9.warn('sdk webrtc hangup, error', error);
6833
+ logger$3.warn('sdk webrtc hangup, error', error);
6796
6834
  }
6797
6835
 
6798
6836
  return null;
@@ -6810,7 +6848,7 @@ class WebRTCClient extends Emitter {
6810
6848
  // Fetch and emit an event at `interval` with session network stats
6811
6849
  startNetworkMonitoring(session , interval = 1000) {
6812
6850
  const sessionId = this.getSipSessionId(session);
6813
- logger$9.info('starting network inspection', { id: sessionId });
6851
+ logger$3.info('starting network inspection', { id: sessionId });
6814
6852
 
6815
6853
  this.sessionNetworkStats[sessionId] = [];
6816
6854
 
@@ -6820,7 +6858,7 @@ class WebRTCClient extends Emitter {
6820
6858
  stopNetworkMonitoring(session ) {
6821
6859
  const sessionId = this.getSipSessionId(session);
6822
6860
  const exists = sessionId in this.networkMonitoringInterval;
6823
- logger$9.info('stopping network inspection', { id: sessionId, exists });
6861
+ logger$3.info('stopping network inspection', { id: sessionId, exists });
6824
6862
 
6825
6863
  if (exists) {
6826
6864
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6830,17 +6868,17 @@ class WebRTCClient extends Emitter {
6830
6868
  }
6831
6869
 
6832
6870
  reject(session ) {
6833
- logger$9.info('sdk webrtc reject call', { id: session.id });
6871
+ logger$3.info('sdk webrtc reject call', { id: session.id });
6834
6872
 
6835
6873
  try {
6836
6874
  return session.reject ? session.reject() : session.cancel();
6837
6875
  } catch (e) {
6838
- logger$9.warn('Error when rejecting call', e.message, e.stack);
6876
+ logger$3.warn('Error when rejecting call', e.message, e.stack);
6839
6877
  }
6840
6878
  }
6841
6879
 
6842
6880
  async close() {
6843
- logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6881
+ logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6844
6882
  this._cleanupMedia();
6845
6883
  this.connectionPromise = null;
6846
6884
 
@@ -6871,7 +6909,7 @@ class WebRTCClient extends Emitter {
6871
6909
  // eg: "INVITE not rejectable in state Completed"
6872
6910
  }
6873
6911
  this.userAgent = null;
6874
- logger$9.info('sdk webrtc client closed');
6912
+ logger$3.info('sdk webrtc client closed');
6875
6913
  }
6876
6914
 
6877
6915
  getNumber(session ) {
@@ -6884,13 +6922,13 @@ class WebRTCClient extends Emitter {
6884
6922
  }
6885
6923
 
6886
6924
  mute(session ) {
6887
- logger$9.info('sdk webrtc mute', { id: session.id });
6925
+ logger$3.info('sdk webrtc mute', { id: session.id });
6888
6926
 
6889
6927
  this._toggleAudio(session, true);
6890
6928
  }
6891
6929
 
6892
6930
  unmute(session ) {
6893
- logger$9.info('sdk webrtc unmute', { id: session.id });
6931
+ logger$3.info('sdk webrtc unmute', { id: session.id });
6894
6932
 
6895
6933
  this._toggleAudio(session, false);
6896
6934
  }
@@ -6930,13 +6968,13 @@ class WebRTCClient extends Emitter {
6930
6968
  }
6931
6969
 
6932
6970
  toggleCameraOn(session ) {
6933
- logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6971
+ logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6934
6972
 
6935
6973
  this._toggleVideo(session, false);
6936
6974
  }
6937
6975
 
6938
6976
  toggleCameraOff(session ) {
6939
- logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6977
+ logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6940
6978
 
6941
6979
  this._toggleVideo(session, true);
6942
6980
  }
@@ -6945,7 +6983,7 @@ class WebRTCClient extends Emitter {
6945
6983
  const sessionId = this.getSipSessionId(session);
6946
6984
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6947
6985
 
6948
- logger$9.info('sdk webrtc hold', {
6986
+ logger$3.info('sdk webrtc hold', {
6949
6987
  sessionId,
6950
6988
  keys: Object.keys(this.heldSessions),
6951
6989
  pendingReinvite: !!session.pendingReinvite,
@@ -6994,7 +7032,7 @@ class WebRTCClient extends Emitter {
6994
7032
  const sessionId = this.getSipSessionId(session);
6995
7033
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
6996
7034
 
6997
- logger$9.info('sdk webrtc unhold', {
7035
+ logger$3.info('sdk webrtc unhold', {
6998
7036
  sessionId,
6999
7037
  keys: Object.keys(this.heldSessions),
7000
7038
  pendingReinvite: !!session.pendingReinvite,
@@ -7142,7 +7180,7 @@ class WebRTCClient extends Emitter {
7142
7180
  if (!session.sessionDescriptionHandler) {
7143
7181
  return;
7144
7182
  }
7145
- logger$9.info('Sending DTMF', {
7183
+ logger$3.info('Sending DTMF', {
7146
7184
  id: this.getSipSessionId(session),
7147
7185
  tone,
7148
7186
  });
@@ -7158,7 +7196,7 @@ class WebRTCClient extends Emitter {
7158
7196
  transfer(session , target ) {
7159
7197
  this.hold(session);
7160
7198
 
7161
- logger$9.info('Transfering a session', {
7199
+ logger$3.info('Transfering a session', {
7162
7200
  id: this.getSipSessionId(session),
7163
7201
  target,
7164
7202
  });
@@ -7180,17 +7218,17 @@ class WebRTCClient extends Emitter {
7180
7218
  atxfer(session ) {
7181
7219
  this.hold(session);
7182
7220
 
7183
- logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7221
+ logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7184
7222
 
7185
7223
  const result = {
7186
7224
  newSession: null,
7187
7225
  init: async (target ) => {
7188
- logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7226
+ logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7189
7227
 
7190
7228
  result.newSession = await this.call(target);
7191
7229
  },
7192
7230
  complete: () => {
7193
- logger$9.info('webrtc transfer completed', {
7231
+ logger$3.info('webrtc transfer completed', {
7194
7232
  id: this.getSipSessionId(session),
7195
7233
  referId: this.getSipSessionId(result.newSession),
7196
7234
  });
@@ -7211,7 +7249,7 @@ class WebRTCClient extends Emitter {
7211
7249
  return;
7212
7250
  }
7213
7251
 
7214
- logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7252
+ logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7215
7253
 
7216
7254
  try {
7217
7255
  sipSession.message({
@@ -7253,7 +7291,7 @@ class WebRTCClient extends Emitter {
7253
7291
  }
7254
7292
 
7255
7293
  changeAudioOutputVolume(volume ) {
7256
- logger$9.info('Changing audio output volume', { volume });
7294
+ logger$3.info('Changing audio output volume', { volume });
7257
7295
 
7258
7296
  Object.values(this.audioElements).forEach(audioElement => {
7259
7297
  if (audioElement instanceof HTMLAudioElement) {
@@ -7265,7 +7303,7 @@ class WebRTCClient extends Emitter {
7265
7303
  }
7266
7304
 
7267
7305
  changeAudioOutputDevice(id ) {
7268
- logger$9.info('Changing audio output device', { id });
7306
+ logger$3.info('Changing audio output device', { id });
7269
7307
 
7270
7308
  Object.values(this.audioElements).forEach(audioElement => {
7271
7309
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7282,7 +7320,7 @@ class WebRTCClient extends Emitter {
7282
7320
 
7283
7321
  changeAudioInputDevice(id , session ) {
7284
7322
  const currentId = this.getAudioDeviceId();
7285
- logger$9.info('setting audio input device', { id, currentId, session: !!session });
7323
+ logger$3.info('setting audio input device', { id, currentId, session: !!session });
7286
7324
 
7287
7325
  if (id === currentId) {
7288
7326
  return null;
@@ -7328,7 +7366,7 @@ class WebRTCClient extends Emitter {
7328
7366
 
7329
7367
  setVideoInputDevice(id ) {
7330
7368
  const currentId = this.getVideoDeviceId();
7331
- logger$9.info('setting video input device', { id, currentId });
7369
+ logger$3.info('setting video input device', { id, currentId });
7332
7370
 
7333
7371
  if (id === currentId) {
7334
7372
  return null;
@@ -7353,7 +7391,7 @@ class WebRTCClient extends Emitter {
7353
7391
  const sessionId = this.getSipSessionId(session);
7354
7392
  const localStream = this.getLocalStream(sessionId);
7355
7393
 
7356
- logger$9.info('changing video input device', { id, sessionId });
7394
+ logger$3.info('changing video input device', { id, sessionId });
7357
7395
 
7358
7396
  // Release old video stream
7359
7397
  if (localStream) {
@@ -7421,7 +7459,7 @@ class WebRTCClient extends Emitter {
7421
7459
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7422
7460
  const desktop = newConstraints && newConstraints.desktop;
7423
7461
 
7424
- logger$9.info('Sending reinvite', {
7462
+ logger$3.info('Sending reinvite', {
7425
7463
  id: this.getSipSessionId(sipSession),
7426
7464
  newConstraints,
7427
7465
  conference,
@@ -7459,7 +7497,7 @@ class WebRTCClient extends Emitter {
7459
7497
  sipSession.incomingInviteRequest.message.body = response.message.body;
7460
7498
  }
7461
7499
 
7462
- logger$9.info('on re-INVITE accepted', {
7500
+ logger$3.info('on re-INVITE accepted', {
7463
7501
  id: this.getSipSessionId(sipSession),
7464
7502
  wasMuted,
7465
7503
  shouldDoScreenSharing,
@@ -7477,7 +7515,7 @@ class WebRTCClient extends Emitter {
7477
7515
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7478
7516
  }
7479
7517
 
7480
- return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7518
+ return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7481
7519
  },
7482
7520
  },
7483
7521
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7578,6 +7616,16 @@ class WebRTCClient extends Emitter {
7578
7616
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7579
7617
  }
7580
7618
 
7619
+ // Useful in a react-native environment when remoteMediaStream is not updated
7620
+ getRemoteVideoStreamFromPc(sessionId ) {
7621
+ const pc = this.getPeerConnection(sessionId);
7622
+ if (!pc) {
7623
+ return null;
7624
+ }
7625
+
7626
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7627
+ }
7628
+
7581
7629
  hasVideo(sessionId ) {
7582
7630
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7583
7631
  }
@@ -7624,7 +7672,7 @@ class WebRTCClient extends Emitter {
7624
7672
  }
7625
7673
 
7626
7674
  startHeartbeat() {
7627
- logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7675
+ logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7628
7676
  if (!this.userAgent) {
7629
7677
  this.heartbeat.stop();
7630
7678
  return;
@@ -7637,7 +7685,7 @@ class WebRTCClient extends Emitter {
7637
7685
  }
7638
7686
 
7639
7687
  stopHeartbeat() {
7640
- logger$9.info('sdk webrtc stop heartbeat');
7688
+ logger$3.info('sdk webrtc stop heartbeat');
7641
7689
  this.heartbeat.stop();
7642
7690
  }
7643
7691
 
@@ -7658,7 +7706,7 @@ class WebRTCClient extends Emitter {
7658
7706
  }
7659
7707
 
7660
7708
  attemptReconnection() {
7661
- logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7709
+ logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7662
7710
  if (!this.userAgent) {
7663
7711
  return;
7664
7712
  }
@@ -7683,7 +7731,7 @@ class WebRTCClient extends Emitter {
7683
7731
  return;
7684
7732
  }
7685
7733
 
7686
- logger$9.info('setting local media stream', {
7734
+ logger$3.info('setting local media stream', {
7687
7735
  sipSessionId,
7688
7736
  tracks: newStream ? newStream.getTracks() : null,
7689
7737
  });
@@ -7700,7 +7748,7 @@ class WebRTCClient extends Emitter {
7700
7748
 
7701
7749
  const oldStream = this.getLocalStream(sipSessionId);
7702
7750
 
7703
- logger$9.info('updating local stream', {
7751
+ logger$3.info('updating local stream', {
7704
7752
  sipSessionId,
7705
7753
  oldStream: !!oldStream,
7706
7754
  tracks: newStream.getTracks(),
@@ -7720,7 +7768,7 @@ class WebRTCClient extends Emitter {
7720
7768
  const remoteStream = this.getRemoteStream(sessionId);
7721
7769
  const pc = this.getPeerConnection(sessionId);
7722
7770
 
7723
- logger$9.info('Updating remote stream', {
7771
+ logger$3.info('Updating remote stream', {
7724
7772
  sessionId,
7725
7773
  tracks: remoteStream ? remoteStream.getTracks() : null,
7726
7774
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7746,7 +7794,7 @@ class WebRTCClient extends Emitter {
7746
7794
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7747
7795
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7748
7796
 
7749
- logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7797
+ logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7750
7798
 
7751
7799
  return {
7752
7800
  constraints: {
@@ -7795,7 +7843,7 @@ class WebRTCClient extends Emitter {
7795
7843
  }
7796
7844
 
7797
7845
  _onTransportError() {
7798
- logger$9.error('on transport error');
7846
+ logger$3.error('on transport error');
7799
7847
  this.eventEmitter.emit(TRANSPORT_ERROR);
7800
7848
  this.attemptReconnection();
7801
7849
  }
@@ -7804,7 +7852,7 @@ class WebRTCClient extends Emitter {
7804
7852
  const body = message && typeof message === 'object' ? message.data : message;
7805
7853
  if (body && body.indexOf('200 OK') !== -1) {
7806
7854
  if (this.hasHeartbeat()) {
7807
- logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7855
+ logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7808
7856
 
7809
7857
  this.heartbeat.onHeartbeat();
7810
7858
  if (this.heartbeatCb) {
@@ -7815,7 +7863,7 @@ class WebRTCClient extends Emitter {
7815
7863
  }
7816
7864
 
7817
7865
  async _onHeartbeatTimeout() {
7818
- logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7866
+ logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7819
7867
 
7820
7868
  if (this.heartbeatTimeoutCb) {
7821
7869
  this.heartbeatTimeoutCb();
@@ -7827,7 +7875,7 @@ class WebRTCClient extends Emitter {
7827
7875
  try {
7828
7876
  await this.userAgent.transport.disconnect();
7829
7877
  } catch (e) {
7830
- logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7878
+ logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7831
7879
  }
7832
7880
  }
7833
7881
 
@@ -7860,31 +7908,31 @@ class WebRTCClient extends Emitter {
7860
7908
  }
7861
7909
 
7862
7910
  _connectIfNeeded() {
7863
- logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7911
+ logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7864
7912
  if (!this.userAgent) {
7865
- logger$9.info('need to recreate User Agent');
7913
+ logger$3.info('need to recreate User Agent');
7866
7914
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7867
7915
  }
7868
7916
 
7869
7917
  if (this.isConnected()) {
7870
- logger$9.info('webrtc sdk, already connected');
7918
+ logger$3.info('webrtc sdk, already connected');
7871
7919
  return Promise.resolve();
7872
7920
  }
7873
7921
 
7874
7922
  if (this.isConnecting()) {
7875
- logger$9.info('webrtc sdk, already connecting...');
7923
+ logger$3.info('webrtc sdk, already connecting...');
7876
7924
 
7877
7925
  this.connectionPromise = this.userAgent.transport.connectPromise;
7878
7926
  return this.connectionPromise;
7879
7927
  }
7880
7928
 
7881
7929
  if (this.connectionPromise) {
7882
- logger$9.info('webrtc sdk, connection promise connecting...');
7930
+ logger$3.info('webrtc sdk, connection promise connecting...');
7883
7931
  // $FlowFixMe
7884
7932
  return this.connectionPromise;
7885
7933
  }
7886
7934
 
7887
- logger$9.info('WebRTC UA needs to connect');
7935
+ logger$3.info('WebRTC UA needs to connect');
7888
7936
 
7889
7937
  // Force UA to reconnect
7890
7938
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8009,7 +8057,7 @@ class WebRTCClient extends Emitter {
8009
8057
 
8010
8058
  sdh.peerConnectionDelegate = {
8011
8059
  onicecandidateerror: (error ) => {
8012
- logger$9.error('on icecandidate error', {
8060
+ logger$3.error('on icecandidate error', {
8013
8061
  address: error.address,
8014
8062
  port: error.port,
8015
8063
  errorCode: error.errorCode,
@@ -8038,7 +8086,7 @@ class WebRTCClient extends Emitter {
8038
8086
  updatedNumber = session.assertedIdentity.uri.normal.user;
8039
8087
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8040
8088
  }
8041
- logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8089
+ logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8042
8090
 
8043
8091
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8044
8092
 
@@ -8054,12 +8102,12 @@ class WebRTCClient extends Emitter {
8054
8102
 
8055
8103
  this._setupMedias(session);
8056
8104
 
8057
- return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8105
+ return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8058
8106
  };
8059
8107
  }
8060
8108
 
8061
8109
  _onAccepted(session , sessionDialog , withEvent = true) {
8062
- logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8110
+ logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8063
8111
 
8064
8112
  this.storeSipSession(session);
8065
8113
 
@@ -8071,14 +8119,14 @@ class WebRTCClient extends Emitter {
8071
8119
  const onTrack = (event ) => {
8072
8120
  const isAudioOnly = this._isAudioOnly(session);
8073
8121
  const { kind, label, readyState, id, muted } = event.track;
8074
- logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8122
+ logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8075
8123
 
8076
8124
  // Stop video track in audio only mode
8077
8125
  if (isAudioOnly && kind === 'video') {
8078
8126
  event.track.stop();
8079
8127
  }
8080
8128
 
8081
- this.eventEmitter.emit(ON_TRACK$1, session, event);
8129
+ this.eventEmitter.emit(ON_TRACK, session, event);
8082
8130
  };
8083
8131
 
8084
8132
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8088,8 +8136,9 @@ class WebRTCClient extends Emitter {
8088
8136
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8089
8137
 
8090
8138
  pc.oniceconnectionstatechange = () => {
8139
+ logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
8091
8140
  if (pc.iceConnectionState === 'disconnected') {
8092
- this.eventEmitter.emit(ON_DISCONNECTED$1);
8141
+ this.eventEmitter.emit(ON_DISCONNECTED);
8093
8142
  }
8094
8143
  };
8095
8144
 
@@ -8260,10 +8309,10 @@ class WebRTCClient extends Emitter {
8260
8309
 
8261
8310
  _stopSendingStats(session ) {
8262
8311
  const sessionId = this.getSipSessionId(session);
8263
- logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8312
+ logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8264
8313
 
8265
8314
  if (sessionId in this.statsIntervals) {
8266
- logger$9.trace('Stop sending stats for call', { sessionId });
8315
+ logger$3.trace('Stop sending stats for call', { sessionId });
8267
8316
  this.statsIntervals[sessionId]();
8268
8317
  delete this.statsIntervals[sessionId];
8269
8318
  }
@@ -8279,7 +8328,7 @@ class WebRTCClient extends Emitter {
8279
8328
  try {
8280
8329
  await this.userAgent.transport.disconnect();
8281
8330
  } catch (e) {
8282
- logger$9.error('WebRTC transport disconnect, error', e);
8331
+ logger$3.error('WebRTC transport disconnect, error', e);
8283
8332
  }
8284
8333
  }
8285
8334
  }
@@ -8316,25 +8365,25 @@ class WebRTCClient extends Emitter {
8316
8365
 
8317
8366
  stats.forEach(report => {
8318
8367
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8319
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8368
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8320
8369
  }
8321
8370
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8322
- audioBytesSent += report.bytesSent;
8371
+ audioBytesSent += Number(report.bytesSent);
8323
8372
  }
8324
8373
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8325
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8374
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8326
8375
  }
8327
8376
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8328
- packetsLost += report.packetsLost;
8329
- networkStats.packetsReceived = report.packetsReceived;
8330
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8377
+ packetsLost += Number(report.packetsLost);
8378
+ networkStats.packetsReceived = Number(report.packetsReceived);
8379
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8331
8380
  }
8332
8381
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8333
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8382
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8334
8383
  }
8335
8384
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8336
8385
  if ('framesPerSecond' in report) {
8337
- networkStats.framesPerSecond = report.framesPerSecond;
8386
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8338
8387
  }
8339
8388
  if ('framerateMean' in report) {
8340
8389
  // framerateMean is only available in FF
@@ -8342,34 +8391,38 @@ class WebRTCClient extends Emitter {
8342
8391
  }
8343
8392
  }
8344
8393
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8345
- packetsLost += report.packetsLost;
8346
- networkStats.roundTripTime = report.roundTripTime;
8347
- networkStats.jitter = report.jitter;
8394
+ packetsLost += Number(report.packetsLost);
8395
+ networkStats.roundTripTime = Number(report.roundTripTime);
8396
+ networkStats.jitter = Number(report.jitter);
8348
8397
  }
8349
8398
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8350
- packetsLost += report.packetsLost;
8399
+ packetsLost += Number(report.packetsLost);
8351
8400
  }
8352
8401
  if (report.type === 'transport') {
8353
- transportSent += report.bytesSent;
8354
- transportReceived += report.bytesReceived;
8402
+ transportSent += Number(report.bytesSent);
8403
+ transportReceived += Number(report.bytesReceived);
8355
8404
  }
8356
8405
  });
8357
8406
 
8358
8407
  networkStats.packetsLost = packetsLost;
8359
- networkStats.audioBytesSent = audioBytesSent;
8408
+ networkStats.totalAudioBytesSent = audioBytesSent;
8409
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8410
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8360
8411
  networkStats.audioBytesReceived = audioBytesReceived;
8361
- networkStats.videoBytesSent = videoBytesSent;
8362
- networkStats.videoBytesReceived = videoBytesReceived;
8412
+ networkStats.totalVideoBytesSent = videoBytesSent;
8413
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8414
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8415
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8416
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8363
8417
  networkStats.transportSent = transportSent;
8364
- networkStats.transportReceived = transportReceived;
8365
-
8366
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8367
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8368
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8418
+ networkStats.totalTransportReceived = transportReceived;
8419
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8369
8420
 
8370
- networkStats.bandwidth = bandwidth;
8421
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8422
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8423
+ + networkStats.transportSent;
8371
8424
 
8372
- this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8425
+ this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8373
8426
  this.sessionNetworkStats[sessionId].push(networkStats);
8374
8427
  }
8375
8428
 
@@ -8397,8 +8450,8 @@ const ON_CALL_FAILED = 'onCallFailed';
8397
8450
  const ON_CALL_ENDED = 'onCallEnded';
8398
8451
  const ON_CALL_ENDING = 'onCallEnding';
8399
8452
  const ON_MESSAGE = 'onMessage';
8400
- const ON_REINVITE = 'reinvite';
8401
- const ON_TRACK = 'onTrack';
8453
+ const ON_REINVITE$1 = 'reinvite';
8454
+ const ON_TRACK$1 = 'onTrack';
8402
8455
  const ON_AUDIO_STREAM = 'onAudioStream';
8403
8456
  const ON_VIDEO_STREAM = 'onVideoStream';
8404
8457
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8413,15 +8466,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8413
8466
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8414
8467
  const ON_CALL_ERROR = 'onCallError';
8415
8468
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8416
- const ON_NETWORK_STATS = 'onNetworkStats';
8469
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
8417
8470
  const ON_CHAT = 'phone/ON_CHAT';
8418
8471
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8419
- const ON_DISCONNECTED = 'onDisconnected';
8472
+ const ON_DISCONNECTED$1 = 'onDisconnected';
8420
8473
 
8421
8474
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8422
8475
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8423
8476
 
8424
- const events = [
8477
+ const events$1 = [
8425
8478
  ON_USER_AGENT,
8426
8479
  ON_REGISTERED,
8427
8480
  ON_UNREGISTERED,
@@ -8439,8 +8492,8 @@ const events = [
8439
8492
  ON_CALL_FAILED,
8440
8493
  ON_CALL_ENDED,
8441
8494
  ON_MESSAGE,
8442
- ON_REINVITE,
8443
- ON_TRACK,
8495
+ ON_REINVITE$1,
8496
+ ON_TRACK$1,
8444
8497
  ON_AUDIO_STREAM,
8445
8498
  ON_VIDEO_STREAM,
8446
8499
  ON_REMOVE_STREAM,
@@ -8455,11 +8508,11 @@ const events = [
8455
8508
  ON_CALL_ERROR,
8456
8509
  ON_CHAT,
8457
8510
  ON_SIGNAL,
8458
- ON_NETWORK_STATS,
8459
- ON_DISCONNECTED,
8511
+ ON_NETWORK_STATS$1,
8512
+ ON_DISCONNECTED$1,
8460
8513
  ];
8461
8514
 
8462
- const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
8515
+ const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
8463
8516
 
8464
8517
  class WebRTCPhone extends Emitter {
8465
8518
 
@@ -8532,7 +8585,7 @@ class WebRTCPhone extends Emitter {
8532
8585
  }).catch(error => {
8533
8586
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8534
8587
  console.error('register error', error, error.message, error.stack);
8535
- logger$8.error('WebRTC register error', { message: error.message, stack: error.stack });
8588
+ logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
8536
8589
  });
8537
8590
  }
8538
8591
 
@@ -8547,7 +8600,7 @@ class WebRTCPhone extends Emitter {
8547
8600
  if (!this.client) {
8548
8601
  return;
8549
8602
  }
8550
- logger$8.info('WebRTC phone stop');
8603
+ logger$4.info('WebRTC phone stop');
8551
8604
  this.client.stop();
8552
8605
  }
8553
8606
 
@@ -8562,7 +8615,7 @@ class WebRTCPhone extends Emitter {
8562
8615
  async sendReinvite(callSession , constraints = null, conference = false,
8563
8616
  audioOnly = false, iceRestart = false) {
8564
8617
  const sipSession = this.findSipSession(callSession);
8565
- logger$8.info('WebRTC phone - send reinvite', {
8618
+ logger$4.info('WebRTC phone - send reinvite', {
8566
8619
  sessionId: sipSession ? sipSession.id : null,
8567
8620
  constraints,
8568
8621
  audioOnly,
@@ -8599,7 +8652,7 @@ class WebRTCPhone extends Emitter {
8599
8652
  }
8600
8653
 
8601
8654
  startHeartbeat() {
8602
- logger$8.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8655
+ logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8603
8656
  if (!this.client || this.client.hasHeartbeat()) {
8604
8657
  return;
8605
8658
  }
@@ -8608,7 +8661,7 @@ class WebRTCPhone extends Emitter {
8608
8661
  }
8609
8662
 
8610
8663
  stopHeartbeat() {
8611
- logger$8.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8664
+ logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8612
8665
  if (!this.client) {
8613
8666
  return;
8614
8667
  }
@@ -8625,7 +8678,7 @@ class WebRTCPhone extends Emitter {
8625
8678
  }
8626
8679
 
8627
8680
  reconnect() {
8628
- logger$8.info('WebRTC phone - reconnect', { client: !!this.client });
8681
+ logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
8629
8682
  if (!this.client) {
8630
8683
  return;
8631
8684
  }
@@ -8666,10 +8719,15 @@ class WebRTCPhone extends Emitter {
8666
8719
  return false;
8667
8720
  }
8668
8721
 
8669
- logger$8.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8722
+ logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8670
8723
 
8671
8724
  this.client.downgradeToAudio(sipSession);
8672
8725
 
8726
+ if (callSession) {
8727
+ callSession.cameraEnabled = false;
8728
+ this._updateCallSession(callSession);
8729
+ }
8730
+
8673
8731
  if (withMessage) {
8674
8732
  this._sendReinviteMessage(callSession, false);
8675
8733
  }
@@ -8684,7 +8742,7 @@ class WebRTCPhone extends Emitter {
8684
8742
  return Promise.resolve(false);
8685
8743
  }
8686
8744
 
8687
- logger$8.info('Upgrade to video', {
8745
+ logger$4.info('Upgrade to video', {
8688
8746
  id: callSession ? callSession.getId() : null,
8689
8747
  constraints,
8690
8748
  isConference,
@@ -8697,6 +8755,11 @@ class WebRTCPhone extends Emitter {
8697
8755
 
8698
8756
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
8699
8757
 
8758
+ if (callSession) {
8759
+ callSession.cameraEnabled = true;
8760
+ this._updateCallSession(callSession);
8761
+ }
8762
+
8700
8763
  // If no stream is returned, it means we have to reinvite
8701
8764
  if (!newStream) {
8702
8765
  return true;
@@ -8719,7 +8782,7 @@ class WebRTCPhone extends Emitter {
8719
8782
 
8720
8783
  _sendReinviteMessage(callSession , isUpgrade ) {
8721
8784
  const sipSession = this.findSipSession(callSession);
8722
- logger$8.info('Sending reinvite message', {
8785
+ logger$4.info('Sending reinvite message', {
8723
8786
  id: callSession ? callSession.getId() : null,
8724
8787
  isUpgrade,
8725
8788
  });
@@ -8745,11 +8808,14 @@ class WebRTCPhone extends Emitter {
8745
8808
  // Monkey patch to know when canceled with the CANCEL message
8746
8809
  const onCancel = sipSession._onCancel.bind(sipSession);
8747
8810
  sipSession._onCancel = (message ) => {
8748
- logger$8.trace('on sip session canceled', { callId: message.callId });
8811
+ logger$4.trace('on sip session canceled', { callId: message.callId });
8749
8812
 
8750
8813
  onCancel(message);
8751
8814
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
8752
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
8815
+ const callSession = this._createCallSession(sipSession);
8816
+ delete this.callSessions[callSession.getId()];
8817
+
8818
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
8753
8819
  };
8754
8820
  } else if (sipSession instanceof invitation.Invitation) {
8755
8821
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -8770,17 +8836,19 @@ class WebRTCPhone extends Emitter {
8770
8836
  this.audioOutputVolume,
8771
8837
  );
8772
8838
  case sessionState.SessionState.Terminating:
8773
- logger$8.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8839
+ logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8774
8840
 
8775
8841
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
8776
8842
 
8777
8843
  break;
8778
8844
  case sessionState.SessionState.Terminated: {
8779
- logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8845
+ logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8780
8846
 
8847
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8848
+ const callSession = this._createCallSession(sipSession);
8781
8849
  const wasCurrentSession = this._onCallTerminated(sipSession);
8782
8850
 
8783
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8851
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8784
8852
  }
8785
8853
  }
8786
8854
  });
@@ -8796,7 +8864,7 @@ class WebRTCPhone extends Emitter {
8796
8864
  const [stream] = event.streams;
8797
8865
  const kind = event && event.track && event.track.kind;
8798
8866
 
8799
- logger$8.info('on track stream called on the peer connection', {
8867
+ logger$4.info('on track stream called on the peer connection', {
8800
8868
  callId: this.getSipSessionId(sipSession),
8801
8869
  streamId: stream ? stream.id : null,
8802
8870
  tracks: stream ? stream.getTracks() : null,
@@ -8816,7 +8884,7 @@ class WebRTCPhone extends Emitter {
8816
8884
  };
8817
8885
 
8818
8886
  peerConnection.onremovestream = event => {
8819
- logger$8.info('on remove stream called on the peer connection', {
8887
+ logger$4.info('on remove stream called on the peer connection', {
8820
8888
  id: event.stream.id,
8821
8889
  tracks: event.stream.getTracks(),
8822
8890
  });
@@ -8826,7 +8894,7 @@ class WebRTCPhone extends Emitter {
8826
8894
  }
8827
8895
 
8828
8896
  async startScreenSharing(constraints , callSession ) {
8829
- logger$8.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8897
+ logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8830
8898
 
8831
8899
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
8832
8900
  if (!screenShareStream) {
@@ -8866,7 +8934,7 @@ class WebRTCPhone extends Emitter {
8866
8934
  return;
8867
8935
  }
8868
8936
 
8869
- logger$8.info('WebRTC phone - stop screen sharing', {
8937
+ logger$4.info('WebRTC phone - stop screen sharing', {
8870
8938
  restoreLocalStream,
8871
8939
  });
8872
8940
 
@@ -8922,24 +8990,26 @@ class WebRTCPhone extends Emitter {
8922
8990
  const pc = this.client.getPeerConnection(sipSessionId);
8923
8991
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
8924
8992
 
8925
- logger$8.info('WebRTC phone - on screensharing', {
8993
+ logger$4.info('WebRTC phone - on screensharing', {
8926
8994
  hadVideo,
8927
8995
  id: this.getSipSessionId(sipSession),
8928
8996
  screenTrack,
8929
8997
  });
8930
8998
 
8931
- screenTrack.onended = () => {
8932
- logger$8.info('WebRTC phone - on screenshare ended', {
8933
- hadVideo,
8934
- id: this.getSipSessionId(sipSession),
8935
- screenTrack,
8936
- });
8999
+ if (screenTrack) {
9000
+ screenTrack.onended = () => {
9001
+ logger$4.info('WebRTC phone - on screenshare ended', {
9002
+ hadVideo,
9003
+ id: this.getSipSessionId(sipSession),
9004
+ screenTrack,
9005
+ });
8937
9006
 
8938
- this.eventEmitter.emit(
8939
- ON_SHARE_SCREEN_ENDING,
8940
- this._createCallSession(sipSession, callSession),
8941
- );
8942
- };
9007
+ this.eventEmitter.emit(
9008
+ ON_SHARE_SCREEN_ENDING,
9009
+ this._createCallSession(sipSession, callSession),
9010
+ );
9011
+ };
9012
+ }
8943
9013
 
8944
9014
  this.currentScreenShare = {
8945
9015
  stream: screenStream,
@@ -8959,7 +9029,7 @@ class WebRTCPhone extends Emitter {
8959
9029
  }
8960
9030
 
8961
9031
  _onCallAccepted(sipSession , cameraEnabled ) {
8962
- logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9032
+ logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
8963
9033
 
8964
9034
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
8965
9035
  this.currentSipSession = sipSession;
@@ -8977,7 +9047,7 @@ class WebRTCPhone extends Emitter {
8977
9047
  }
8978
9048
 
8979
9049
  changeAudioDevice(id ) {
8980
- logger$8.info('WebRTC phone - change audio device', { deviceId: id });
9050
+ logger$4.info('WebRTC phone - change audio device', { deviceId: id });
8981
9051
  this.audioOutputDeviceId = id;
8982
9052
  this.client.changeAudioOutputDevice(id);
8983
9053
  }
@@ -8987,14 +9057,14 @@ class WebRTCPhone extends Emitter {
8987
9057
  }
8988
9058
 
8989
9059
  changeRingDevice(id ) {
8990
- logger$8.info('WebRTC phone - changing ring device', { id });
9060
+ logger$4.info('WebRTC phone - changing ring device', { id });
8991
9061
 
8992
9062
  this.audioRingDeviceId = id;
8993
9063
  }
8994
9064
 
8995
9065
  // volume is a value between 0 and 1
8996
9066
  changeAudioVolume(volume ) {
8997
- logger$8.info('WebRTC phone - changing audio volume', { volume });
9067
+ logger$4.info('WebRTC phone - changing audio volume', { volume });
8998
9068
 
8999
9069
  this.audioOutputVolume = volume;
9000
9070
  this.client.changeAudioOutputVolume(volume);
@@ -9002,31 +9072,31 @@ class WebRTCPhone extends Emitter {
9002
9072
 
9003
9073
  // volume is a value between 0 and 1
9004
9074
  changeRingVolume(volume ) {
9005
- logger$8.info('WebRTC phone - changing ring volume', { volume });
9075
+ logger$4.info('WebRTC phone - changing ring volume', { volume });
9006
9076
 
9007
9077
  this.audioRingVolume = volume;
9008
9078
  }
9009
9079
 
9010
9080
  changeAudioInputDevice(id ) {
9011
- logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9081
+ logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
9012
9082
 
9013
9083
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9014
9084
  }
9015
9085
 
9016
9086
  changeVideoInputDevice(id ) {
9017
- logger$8.info('WebRTC phone - change video input device', { deviceId: id });
9087
+ logger$4.info('WebRTC phone - change video input device', { deviceId: id });
9018
9088
 
9019
9089
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9020
9090
  }
9021
9091
 
9022
9092
  changeSessionVideoInputDevice(id ) {
9023
- logger$8.info('WebRTC phone - change session video input device', { deviceId: id });
9093
+ logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
9024
9094
 
9025
9095
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9026
9096
  }
9027
9097
 
9028
9098
  _onCallTerminated(sipSession ) {
9029
- logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9099
+ logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9030
9100
 
9031
9101
  const callSession = this._createCallSession(sipSession);
9032
9102
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -9060,7 +9130,7 @@ class WebRTCPhone extends Emitter {
9060
9130
  const hasIncomingCallSession = this.hasIncomingCallSession();
9061
9131
 
9062
9132
  // Re-trigger incoming call event for remaining incoming calls
9063
- logger$8.info('WebRTC phone - check to re-trigger incoming call', {
9133
+ logger$4.info('WebRTC phone - check to re-trigger incoming call', {
9064
9134
  sipId: sipSession.id,
9065
9135
  shouldRetrigger,
9066
9136
  hasIncomingCallSession,
@@ -9151,37 +9221,37 @@ class WebRTCPhone extends Emitter {
9151
9221
 
9152
9222
  // Deprecated
9153
9223
  getLocalStreamForCall(callSession ) {
9154
- logger$8.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9224
+ logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9155
9225
 
9156
9226
  return this.getLocalStream(callSession);
9157
9227
  }
9158
9228
 
9159
9229
  // Deprecated
9160
9230
  getRemoteStreamForCall(callSession ) {
9161
- logger$8.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9231
+ logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9162
9232
 
9163
9233
  return this.getRemoteVideoStream(callSession);
9164
9234
  }
9165
9235
 
9166
9236
  getRemoteStreamsForCall(callSession ) {
9167
- logger$8.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9237
+ logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9168
9238
 
9169
9239
  return this.getRemoteStream(callSession);
9170
9240
  }
9171
9241
 
9172
9242
  accept(callSession , cameraEnabled ) {
9173
- logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9243
+ logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9174
9244
  if (this.currentSipSession) {
9175
9245
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9176
9246
  }
9177
9247
 
9178
9248
  if (!callSession) {
9179
- logger$8.warn('no CallSession to accept.');
9249
+ logger$4.warn('no CallSession to accept.');
9180
9250
  return Promise.resolve(null);
9181
9251
  }
9182
9252
 
9183
9253
  if (callSession.getId() in this.acceptedSessions) {
9184
- logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9254
+ logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9185
9255
  return Promise.resolve(callSession.sipCallId);
9186
9256
  }
9187
9257
 
@@ -9193,24 +9263,24 @@ class WebRTCPhone extends Emitter {
9193
9263
  const sipSession = this.client.getSipSession(callSession.getId());
9194
9264
  if (sipSession) {
9195
9265
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9196
- logger$8.warn('Trying to answer a terminated sipSession.');
9266
+ logger$4.warn('Trying to answer a terminated sipSession.');
9197
9267
 
9198
9268
  return Promise.resolve(null);
9199
9269
  }
9200
9270
 
9201
- logger$8.info('accept call, session found', { sipId: sipSession.id });
9271
+ logger$4.info('accept call, session found', { sipId: sipSession.id });
9202
9272
 
9203
9273
  // $FlowFixMe
9204
9274
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9205
9275
  return callSession.sipCallId;
9206
9276
  }).catch(e => {
9207
- logger$8.error(e);
9277
+ logger$4.error(e);
9208
9278
  this.endCurrentCall(callSession);
9209
9279
  throw e;
9210
9280
  });
9211
9281
  }
9212
9282
 
9213
- logger$8.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9283
+ logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9214
9284
 
9215
9285
  return Promise.resolve(null);
9216
9286
  }
@@ -9220,7 +9290,7 @@ class WebRTCPhone extends Emitter {
9220
9290
  }
9221
9291
 
9222
9292
  async reject(callSession ) {
9223
- logger$8.info('reject WebRTC called', { id: callSession.getId() });
9293
+ logger$4.info('reject WebRTC called', { id: callSession.getId() });
9224
9294
 
9225
9295
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9226
9296
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9232,14 +9302,14 @@ class WebRTCPhone extends Emitter {
9232
9302
 
9233
9303
  const sipSession = this.findSipSession(callSession);
9234
9304
  if (sipSession) {
9235
- logger$8.info('WebRTC rejecting', { sipId: sipSession.id });
9305
+ logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
9236
9306
 
9237
9307
  this.client.hangup(sipSession);
9238
9308
  }
9239
9309
  }
9240
9310
 
9241
9311
  async ignore(callSession ) {
9242
- logger$8.info('WebRTC ignore', { id: callSession.getId() });
9312
+ logger$4.info('WebRTC ignore', { id: callSession.getId() });
9243
9313
 
9244
9314
  // kill the ring
9245
9315
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9251,14 +9321,14 @@ class WebRTCPhone extends Emitter {
9251
9321
  const sipSession = this.findSipSession(callSession);
9252
9322
 
9253
9323
  if (sipSession) {
9254
- logger$8.info('WebRTC atxfer', { sipId: sipSession.id });
9324
+ logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
9255
9325
 
9256
9326
  return this.client.atxfer(sipSession);
9257
9327
  }
9258
9328
  }
9259
9329
 
9260
9330
  hold(callSession , withEvent = true, isConference = false) {
9261
- logger$8.info('WebRTC hold', { id: callSession.getId() });
9331
+ logger$4.info('WebRTC hold', { id: callSession.getId() });
9262
9332
 
9263
9333
  const sipSession = this.findSipSession(callSession);
9264
9334
 
@@ -9273,18 +9343,18 @@ class WebRTCPhone extends Emitter {
9273
9343
  }
9274
9344
 
9275
9345
  resume(callSession , isConference = false, withEvent = true) {
9276
- logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9346
+ logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9277
9347
 
9278
9348
  const sipSession = this.findSipSession(callSession);
9279
9349
  if (!sipSession) {
9280
9350
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9281
9351
  }
9282
9352
 
9283
- logger$8.info('WebRTC resuming', { sipId: sipSession.id });
9353
+ logger$4.info('WebRTC resuming', { sipId: sipSession.id });
9284
9354
 
9285
9355
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9286
9356
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9287
- logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9357
+ logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9288
9358
  this.holdSipSession(this.currentSipSession, callSession);
9289
9359
  }
9290
9360
 
@@ -9309,7 +9379,7 @@ class WebRTCPhone extends Emitter {
9309
9379
  const sessionId = this.getSipSessionId(sipSession);
9310
9380
  const hasVideo = this.client.hasLocalVideo(sessionId);
9311
9381
 
9312
- logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9382
+ logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9313
9383
 
9314
9384
  // Stop screenshre if needed
9315
9385
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9340,7 +9410,7 @@ class WebRTCPhone extends Emitter {
9340
9410
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9341
9411
  }
9342
9412
  const sessionId = this.getSipSessionId(sipSession);
9343
- logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9413
+ logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
9344
9414
 
9345
9415
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9346
9416
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9384,14 +9454,14 @@ class WebRTCPhone extends Emitter {
9384
9454
  }
9385
9455
 
9386
9456
  mute(callSession , withEvent = true) {
9387
- logger$8.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9457
+ logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9388
9458
 
9389
9459
  const sipSession = this.findSipSession(callSession);
9390
9460
  if (!sipSession) {
9391
9461
  return;
9392
9462
  }
9393
9463
 
9394
- logger$8.info('WebRTC muting', { sipId: sipSession.id });
9464
+ logger$4.info('WebRTC muting', { sipId: sipSession.id });
9395
9465
  this.client.mute(sipSession);
9396
9466
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9397
9467
 
@@ -9405,14 +9475,14 @@ class WebRTCPhone extends Emitter {
9405
9475
  }
9406
9476
 
9407
9477
  unmute(callSession , withEvent = true) {
9408
- logger$8.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9478
+ logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9409
9479
 
9410
9480
  const sipSession = this.findSipSession(callSession);
9411
9481
  if (!sipSession) {
9412
9482
  return;
9413
9483
  }
9414
9484
 
9415
- logger$8.info('WebRTC unmuting', { sipId: sipSession.id });
9485
+ logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
9416
9486
  this.client.unmute(sipSession);
9417
9487
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9418
9488
 
@@ -9439,7 +9509,7 @@ class WebRTCPhone extends Emitter {
9439
9509
  if (!sipSession) {
9440
9510
  return;
9441
9511
  }
9442
- logger$8.info('WebRTC turn camera on', { sipId: sipSession.id });
9512
+ logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
9443
9513
 
9444
9514
  this.client.toggleCameraOn(sipSession);
9445
9515
 
@@ -9451,7 +9521,7 @@ class WebRTCPhone extends Emitter {
9451
9521
  if (!sipSession) {
9452
9522
  return;
9453
9523
  }
9454
- logger$8.info('WebRTC turn camera off', { sipId: sipSession.id });
9524
+ logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
9455
9525
 
9456
9526
  this.client.toggleCameraOff(sipSession);
9457
9527
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9463,7 +9533,7 @@ class WebRTCPhone extends Emitter {
9463
9533
  return;
9464
9534
  }
9465
9535
 
9466
- logger$8.info('WebRTC send key', { sipId: sipSession.id, tone });
9536
+ logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
9467
9537
  this.client.sendDTMF(sipSession, tone);
9468
9538
  }
9469
9539
 
@@ -9471,7 +9541,7 @@ class WebRTCPhone extends Emitter {
9471
9541
  // @TODO: line is not used here
9472
9542
  async makeCall(number , line , cameraEnabled ,
9473
9543
  audioOnly = false, conference = false) {
9474
- logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9544
+ logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9475
9545
  if (!number) {
9476
9546
  return Promise.resolve(null);
9477
9547
  }
@@ -9481,7 +9551,7 @@ class WebRTCPhone extends Emitter {
9481
9551
  }
9482
9552
  if (this.currentSipSession) {
9483
9553
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9484
- logger$8.warn('Unable to hold current session when making another call', e);
9554
+ logger$4.warn('Unable to hold current session when making another call', e);
9485
9555
  });
9486
9556
  }
9487
9557
 
@@ -9491,7 +9561,7 @@ class WebRTCPhone extends Emitter {
9491
9561
  this._bindEvents(sipSession);
9492
9562
  } catch (error) {
9493
9563
  console.warn(error);
9494
- logger$8.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9564
+ logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9495
9565
  return Promise.resolve(null);
9496
9566
  }
9497
9567
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -9519,7 +9589,7 @@ class WebRTCPhone extends Emitter {
9519
9589
  return;
9520
9590
  }
9521
9591
 
9522
- logger$8.info('WebRTC transfer', { sipId: sipSession.id, target });
9592
+ logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
9523
9593
 
9524
9594
  this.client.transfer(sipSession, target);
9525
9595
  }
@@ -9528,7 +9598,7 @@ class WebRTCPhone extends Emitter {
9528
9598
  const sipSession = this.client.getSipSession(source.sipCallId);
9529
9599
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9530
9600
 
9531
- logger$8.info('WebRTC indirect transfer', {
9601
+ logger$4.info('WebRTC indirect transfer', {
9532
9602
  sipId: sipSession ? sipSession.id : null,
9533
9603
  target: sipSessionTarget ? sipSessionTarget.id : null,
9534
9604
  });
@@ -9567,7 +9637,7 @@ class WebRTCPhone extends Emitter {
9567
9637
  return false;
9568
9638
  }
9569
9639
 
9570
- logger$8.info('WebRTC hangup', { sipId: sipSession.id });
9640
+ logger$4.info('WebRTC hangup', { sipId: sipSession.id });
9571
9641
 
9572
9642
  const sipSessionId = this.getSipSessionId(sipSession);
9573
9643
 
@@ -9613,7 +9683,7 @@ class WebRTCPhone extends Emitter {
9613
9683
  endCurrentCall(callSession ) {
9614
9684
  const isCurrent = this.isCurrentCallSipSession(callSession);
9615
9685
 
9616
- logger$8.info('Ending current call', {
9686
+ logger$4.info('Ending current call', {
9617
9687
  id: callSession ? callSession.getId() : null,
9618
9688
  isCurrent,
9619
9689
  });
@@ -9637,7 +9707,7 @@ class WebRTCPhone extends Emitter {
9637
9707
  }
9638
9708
 
9639
9709
  async close() {
9640
- logger$8.info('WebRTC close');
9710
+ logger$4.info('WebRTC close');
9641
9711
 
9642
9712
  try {
9643
9713
  await Promise.race([
@@ -9645,7 +9715,7 @@ class WebRTCPhone extends Emitter {
9645
9715
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9646
9716
  ]);
9647
9717
  } catch (e) {
9648
- logger$8.error('WebRTC close, unregister error', e);
9718
+ logger$4.error('WebRTC close, unregister error', e);
9649
9719
  }
9650
9720
 
9651
9721
  this.client.close();
@@ -9663,12 +9733,12 @@ class WebRTCPhone extends Emitter {
9663
9733
  }
9664
9734
 
9665
9735
  enableRinging() {
9666
- logger$8.info('WebRTC enable ringing');
9736
+ logger$4.info('WebRTC enable ringing');
9667
9737
  this.ringingEnabled = true;
9668
9738
  }
9669
9739
 
9670
9740
  disableRinging() {
9671
- logger$8.info('WebRTC disable ringing');
9741
+ logger$4.info('WebRTC disable ringing');
9672
9742
  this.ringingEnabled = false;
9673
9743
  }
9674
9744
 
@@ -9708,7 +9778,7 @@ class WebRTCPhone extends Emitter {
9708
9778
 
9709
9779
  // Deprecated
9710
9780
  getLocalMediaStream(callSession ) {
9711
- logger$8.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9781
+ logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9712
9782
  return this.getLocalStream(callSession);
9713
9783
  }
9714
9784
 
@@ -9728,6 +9798,10 @@ class WebRTCPhone extends Emitter {
9728
9798
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9729
9799
  }
9730
9800
 
9801
+ getRemoteVideoStreamFromPc(callSession ) {
9802
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9803
+ }
9804
+
9731
9805
  hasRemoteVideo(callSession ) {
9732
9806
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9733
9807
  }
@@ -9746,7 +9820,7 @@ class WebRTCPhone extends Emitter {
9746
9820
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
9747
9821
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
9748
9822
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
9749
- logger$8.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9823
+ logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9750
9824
 
9751
9825
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
9752
9826
  this.incomingSessions.push(callSession.getId());
@@ -9769,7 +9843,7 @@ class WebRTCPhone extends Emitter {
9769
9843
  });
9770
9844
 
9771
9845
  this.client.on(this.client.ON_REINVITE, (...args) => {
9772
- logger$8.info('WebRTC on reinvite', {
9846
+ logger$4.info('WebRTC on reinvite', {
9773
9847
  sessionId: args[0].id,
9774
9848
  inviteId: args[1].id,
9775
9849
  updatedCalleeName: args[2],
@@ -9789,7 +9863,7 @@ class WebRTCPhone extends Emitter {
9789
9863
  });
9790
9864
 
9791
9865
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9792
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9866
+ logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
9793
9867
 
9794
9868
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
9795
9869
 
@@ -9800,22 +9874,22 @@ class WebRTCPhone extends Emitter {
9800
9874
  this.client.on('ended', () => {});
9801
9875
 
9802
9876
  this.client.on(this.client.ON_ERROR, e => {
9803
- logger$8.error('WebRTC error', e);
9877
+ logger$4.error('WebRTC error', e);
9804
9878
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9805
9879
  });
9806
9880
 
9807
9881
  this.client.on(this.client.UNREGISTERED, () => {
9808
- logger$8.info('WebRTC unregistered');
9882
+ logger$4.info('WebRTC unregistered');
9809
9883
  this.eventEmitter.emit(ON_UNREGISTERED);
9810
9884
  });
9811
9885
 
9812
9886
  this.client.on(this.client.ON_DISCONNECTED, () => {
9813
- logger$8.info('WebRTC disconnected');
9814
- this.eventEmitter.emit(ON_DISCONNECTED);
9887
+ logger$4.info('WebRTC disconnected');
9888
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
9815
9889
  });
9816
9890
 
9817
9891
  this.client.on(this.client.REGISTERED, () => {
9818
- logger$8.info('WebRTC registered', {
9892
+ logger$4.info('WebRTC registered', {
9819
9893
  shouldSendReinvite: this.shouldSendReinvite,
9820
9894
  state: this.currentSipSession ? this.currentSipSession.state : null,
9821
9895
  currentSipSession: !!this.currentSipSession,
@@ -9828,23 +9902,27 @@ class WebRTCPhone extends Emitter {
9828
9902
  if (this.shouldSendReinvite && this.currentSipSession
9829
9903
  && this.currentSipSession.state === sessionState.SessionState.Established) {
9830
9904
  this.shouldSendReinvite = false;
9905
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
9906
+ const isConference = pc ? pc.sfu : false;
9907
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
9908
+
9831
9909
  try {
9832
9910
  // Send reinvite with iceRestart
9833
- this.sendReinvite(this.currentCallSession, null, false, false, true);
9911
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
9834
9912
  } catch (e) {
9835
- logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9913
+ logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9836
9914
  }
9837
9915
  }
9838
9916
  });
9839
9917
 
9840
9918
  this.client.on(this.client.CONNECTED, () => {
9841
- logger$8.info('WebRTC client connected');
9919
+ logger$4.info('WebRTC client connected');
9842
9920
 
9843
9921
  this.stopHeartbeat();
9844
9922
  });
9845
9923
 
9846
9924
  this.client.on(this.client.DISCONNECTED, () => {
9847
- logger$8.info('WebRTC client disconnected');
9925
+ logger$4.info('WebRTC client disconnected');
9848
9926
 
9849
9927
  this.eventEmitter.emit(ON_UNREGISTERED);
9850
9928
 
@@ -9858,7 +9936,7 @@ class WebRTCPhone extends Emitter {
9858
9936
  });
9859
9937
 
9860
9938
  this.client.on(this.client.ON_TRACK, (session, event) => {
9861
- this.eventEmitter.emit(ON_TRACK, session, event);
9939
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
9862
9940
  });
9863
9941
 
9864
9942
  this.client.on('onVideoInputChange', stream => {
@@ -9873,7 +9951,7 @@ class WebRTCPhone extends Emitter {
9873
9951
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
9874
9952
  const callSession = this.getCallSession(this.getSipSessionId(session));
9875
9953
 
9876
- this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
9954
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
9877
9955
  });
9878
9956
 
9879
9957
  // Used when upgrading directly in screenshare mode
@@ -9882,7 +9960,7 @@ class WebRTCPhone extends Emitter {
9882
9960
  const localStream = this.client.getLocalStream(sipSessionId);
9883
9961
  const callSession = this.callSessions[sipSessionId];
9884
9962
 
9885
- logger$8.info('Updrading directly in screensharing mode', {
9963
+ logger$4.info('Updrading directly in screensharing mode', {
9886
9964
  sipSessionId,
9887
9965
  tracks: localStream ? localStream.getTracks() : null,
9888
9966
  });
@@ -9914,6 +9992,15 @@ class WebRTCPhone extends Emitter {
9914
9992
  return this.client.getSipSessionId(sipSession);
9915
9993
  }
9916
9994
 
9995
+ _updateCallSession(callSession ) {
9996
+ const sipSession = this.findSipSession(callSession);
9997
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
9998
+
9999
+ if (sipSessionId) {
10000
+ this.callSessions[sipSessionId] = callSession;
10001
+ }
10002
+ }
10003
+
9917
10004
  _onMessage(message ) {
9918
10005
  if (!message || message.method !== 'MESSAGE') {
9919
10006
  return;
@@ -10051,8 +10138,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10051
10138
  ON_CALL_ENDED: ON_CALL_ENDED,
10052
10139
  ON_CALL_ENDING: ON_CALL_ENDING,
10053
10140
  ON_MESSAGE: ON_MESSAGE,
10054
- ON_REINVITE: ON_REINVITE,
10055
- ON_TRACK: ON_TRACK,
10141
+ ON_REINVITE: ON_REINVITE$1,
10142
+ ON_TRACK: ON_TRACK$1,
10056
10143
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10057
10144
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10058
10145
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10067,19 +10154,19 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10067
10154
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10068
10155
  ON_CALL_ERROR: ON_CALL_ERROR,
10069
10156
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10070
- ON_NETWORK_STATS: ON_NETWORK_STATS,
10157
+ ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10071
10158
  ON_CHAT: ON_CHAT,
10072
10159
  ON_SIGNAL: ON_SIGNAL,
10073
- ON_DISCONNECTED: ON_DISCONNECTED,
10160
+ ON_DISCONNECTED: ON_DISCONNECTED$1,
10074
10161
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10075
10162
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10076
- events: events,
10163
+ events: events$1,
10077
10164
  'default': WebRTCPhone
10078
10165
  });
10079
10166
 
10080
10167
  //
10081
10168
 
10082
- const logger$7 = IssueReporter$1.loggerFor('simple-phone');
10169
+ const logger$5 = IssueReporter$1.loggerFor('simple-phone');
10083
10170
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
10084
10171
  const protocolLogger = IssueReporter$1.loggerFor('sip');
10085
10172
 
@@ -10186,7 +10273,7 @@ class Phone extends Emitter {
10186
10273
  async disconnect() {
10187
10274
  if (this.phone) {
10188
10275
  if (this.phone.hasAnActiveCall()) {
10189
- logger$7.info('hangup call on disconnect');
10276
+ logger$5.info('hangup call on disconnect');
10190
10277
  // $FlowFixMe
10191
10278
  await this.phone.hangup();
10192
10279
  }
@@ -10209,13 +10296,13 @@ class Phone extends Emitter {
10209
10296
  }
10210
10297
 
10211
10298
  async hangup(callSession ) {
10212
- logger$7.info('hangup via simple phone', { callId: callSession.getId() });
10299
+ logger$5.info('hangup via simple phone', { callId: callSession.getId() });
10213
10300
 
10214
10301
  return this.phone && this.phone.hangup(callSession);
10215
10302
  }
10216
10303
 
10217
10304
  async accept(callSession , cameraEnabled ) {
10218
- logger$7.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10305
+ logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10219
10306
 
10220
10307
  return this.phone && this.phone.accept(callSession, cameraEnabled);
10221
10308
  }
@@ -10254,7 +10341,7 @@ class Phone extends Emitter {
10254
10341
  muteViaAPI(callSession ) {
10255
10342
  if (callSession && callSession.callId) {
10256
10343
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
10257
- logger$7.error('Mute via API, error', e);
10344
+ logger$5.error('Mute via API, error', e);
10258
10345
  });
10259
10346
  }
10260
10347
  }
@@ -10262,7 +10349,7 @@ class Phone extends Emitter {
10262
10349
  unmuteViaAPI(callSession ) {
10263
10350
  if (callSession && callSession.callId) {
10264
10351
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
10265
- logger$7.error('Unmute via API, error', e);
10352
+ logger$5.error('Unmute via API, error', e);
10266
10353
  });
10267
10354
  }
10268
10355
  }
@@ -10370,7 +10457,7 @@ class Phone extends Emitter {
10370
10457
 
10371
10458
  // @Deprecated
10372
10459
  getLocalMediaStream(callSession ) {
10373
- logger$7.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10460
+ logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10374
10461
 
10375
10462
  return this.phone && this.phone.getLocalStream(callSession);
10376
10463
  }
@@ -10393,24 +10480,29 @@ class Phone extends Emitter {
10393
10480
 
10394
10481
  // @Deprecated
10395
10482
  getRemoteStreamForCall(callSession ) {
10396
- logger$7.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10483
+ logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10397
10484
  return this.getRemoteStream(callSession);
10398
10485
  }
10399
10486
 
10400
10487
  // Returns remote streams directly from the peerConnection
10401
10488
  // @Deprecated
10402
10489
  getRemoteStreamsForCall(callSession ) {
10403
- logger$7.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10490
+ logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10404
10491
  return this.getLocalStream(callSession);
10405
10492
  }
10406
10493
 
10407
10494
  // @Deprecated
10408
10495
  getRemoteVideoStreamForCall(callSession ) {
10409
- logger$7.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10496
+ logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10410
10497
 
10411
10498
  return this.getRemoteVideoStream(callSession);
10412
10499
  }
10413
10500
 
10501
+ // Useful in a react-native environment when remoteMediaStream is not updated
10502
+ getRemoteVideoStreamFromPc(callSession ) {
10503
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10504
+ }
10505
+
10414
10506
  hasVideo(callSession ) {
10415
10507
  return this.phone ? this.phone.hasVideo(callSession) : false;
10416
10508
  }
@@ -10462,7 +10554,7 @@ class Phone extends Emitter {
10462
10554
 
10463
10555
  _transferEvents() {
10464
10556
  this.unbind();
10465
- [...events$1, ...transportEvents].forEach(event => {
10557
+ [...events, ...transportEvents].forEach(event => {
10466
10558
  this.client.on(event, (...args) =>
10467
10559
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10468
10560
  });
@@ -10484,7 +10576,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10484
10576
 
10485
10577
  //
10486
10578
 
10487
- const SOCKET_EVENTS$1 = {
10579
+ const SOCKET_EVENTS = {
10488
10580
  ON_OPEN: 'onopen',
10489
10581
  ON_MESSAGE: 'onmessage',
10490
10582
  ON_ERROR: 'onerror',
@@ -10570,6 +10662,7 @@ const AGENT_PAUSED = 'agent_paused';
10570
10662
  const AGENT_UNPAUSED = 'agent_unpaused';
10571
10663
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10572
10664
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10665
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10573
10666
 
10574
10667
  const BLACKLIST_EVENTS = [
10575
10668
  CHAT_MESSAGE_SENT,
@@ -10636,16 +10729,16 @@ class WebSocketClient extends Emitter {
10636
10729
 
10637
10730
  this.socket.onopen = () => {
10638
10731
  logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
10639
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10732
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10640
10733
  };
10641
10734
 
10642
10735
  this.socket.onerror = event => {
10643
10736
  logger$6.error('on Wazo WS error', event.target);
10644
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10737
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10645
10738
  };
10646
10739
 
10647
10740
  this.socket.onmessage = (event ) => {
10648
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
10741
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10649
10742
 
10650
10743
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10651
10744
  let { name } = message;
@@ -10678,11 +10771,11 @@ class WebSocketClient extends Emitter {
10678
10771
  token: this.token,
10679
10772
  });
10680
10773
  this.initialized = false;
10681
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
10774
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10682
10775
 
10683
10776
  switch (event.code) {
10684
10777
  case 4002:
10685
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
10778
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10686
10779
  break;
10687
10780
  }
10688
10781
  };
@@ -10798,7 +10891,7 @@ class WebSocketClient extends Emitter {
10798
10891
  break;
10799
10892
  case 'start':
10800
10893
  this.initialized = true;
10801
- this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
10894
+ this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
10802
10895
  break;
10803
10896
  default:
10804
10897
  this.eventEmitter.emit('message', message);
@@ -10845,7 +10938,7 @@ class WebSocketClient extends Emitter {
10845
10938
  logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
10846
10939
 
10847
10940
  this.close();
10848
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
10941
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
10849
10942
 
10850
10943
  if (this.onHeartBeatTimeout) {
10851
10944
  this.onHeartBeatTimeout();
@@ -10920,11 +11013,12 @@ WebSocketClient.eventLists = [
10920
11013
  AGENT_UNPAUSED,
10921
11014
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10922
11015
  CONFERENCE_ADHOC_DELETED,
11016
+ MEETING_USER_PROGRESS,
10923
11017
  ];
10924
11018
 
10925
11019
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10926
11020
  __proto__: null,
10927
- SOCKET_EVENTS: SOCKET_EVENTS$1,
11021
+ SOCKET_EVENTS: SOCKET_EVENTS,
10928
11022
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
10929
11023
  FAVORITE_ADDED: FAVORITE_ADDED,
10930
11024
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -10990,16 +11084,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10990
11084
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10991
11085
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10992
11086
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11087
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10993
11088
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10994
11089
  'default': WebSocketClient
10995
11090
  });
10996
11091
 
10997
11092
  //
10998
11093
 
10999
- const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11000
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11094
+ const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11095
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11001
11096
 
11002
- const logger$5 = IssueReporter$1.loggerFor('simple-ws-client');
11097
+ const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
11003
11098
 
11004
11099
  class Websocket extends Emitter {
11005
11100
 
@@ -11013,9 +11108,9 @@ class Websocket extends Emitter {
11013
11108
  // $FlowFixMe
11014
11109
  this[key] = OTHER_EVENTS[key];
11015
11110
  });
11016
- Object.keys(SOCKET_EVENTS).forEach(key => {
11111
+ Object.keys(SOCKET_EVENTS$1).forEach(key => {
11017
11112
  // $FlowFixMe
11018
- this[key] = SOCKET_EVENTS[key];
11113
+ this[key] = SOCKET_EVENTS$1[key];
11019
11114
  });
11020
11115
  this.eventLists = WebSocketClient.eventLists;
11021
11116
 
@@ -11023,7 +11118,7 @@ class Websocket extends Emitter {
11023
11118
  }
11024
11119
 
11025
11120
  open(host , session ) {
11026
- logger$5.info('open simple WebSocket', { host, token: session.token });
11121
+ logger$7.info('open simple WebSocket', { host, token: session.token });
11027
11122
  this.ws = new WebSocketClient(
11028
11123
  {
11029
11124
  host,
@@ -11051,7 +11146,7 @@ class Websocket extends Emitter {
11051
11146
  }
11052
11147
 
11053
11148
  updateToken(token ) {
11054
- logger$5.info('update token via simple Websocket', { token, ws: !!this.ws });
11149
+ logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
11055
11150
 
11056
11151
  if (!this.ws) {
11057
11152
  return;
@@ -11079,7 +11174,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11079
11174
 
11080
11175
  //
11081
11176
 
11082
- const logger$4 = IssueReporter$1.loggerFor('room');
11177
+ const logger$8 = IssueReporter$1.loggerFor('room');
11083
11178
 
11084
11179
  class Participant extends Emitter {
11085
11180
 
@@ -11201,7 +11296,7 @@ class Participant extends Emitter {
11201
11296
  }
11202
11297
 
11203
11298
  onTalking(isTalking ) {
11204
- logger$4.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11299
+ logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11205
11300
  this.isTalking = isTalking;
11206
11301
  // you may notice we're not broadcasting: since all participants are getting this info
11207
11302
  // directly from asterisk, there's no need to do so
@@ -11304,7 +11399,7 @@ class Participant extends Emitter {
11304
11399
  }
11305
11400
 
11306
11401
  updateStatus(status , broadcast = true) {
11307
- logger$4.info('updating participant status', { name: this.name, status });
11402
+ logger$8.info('updating participant status', { name: this.name, status });
11308
11403
 
11309
11404
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11310
11405
  if (status.audioMuted) {
@@ -11352,7 +11447,7 @@ class Participant extends Emitter {
11352
11447
 
11353
11448
  broadcastStatus(inboundStatus = null) {
11354
11449
  const status = inboundStatus || this.getStatus();
11355
- logger$4.info('broadcasting participant status', { callId: this.callId, status });
11450
+ logger$8.info('broadcasting participant status', { callId: this.callId, status });
11356
11451
 
11357
11452
  this.room.sendSignal({
11358
11453
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11388,9 +11483,9 @@ class LocalParticipant extends Participant {
11388
11483
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11389
11484
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11390
11485
 
11391
- const logger$3 = IssueReporter$1.loggerFor('sdk-room');
11486
+ const logger$9 = IssueReporter$1.loggerFor('sdk-room');
11392
11487
 
11393
- class Room$1 extends Emitter {
11488
+ class Room extends Emitter {
11394
11489
 
11395
11490
 
11396
11491
 
@@ -11448,7 +11543,7 @@ class Room$1 extends Emitter {
11448
11543
  extra = {},
11449
11544
  ) {
11450
11545
  super();
11451
- logger$3.info('room initialized', { callId, extension, sourceId, meetingUuid });
11546
+ logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
11452
11547
 
11453
11548
  // Represents the room callSession
11454
11549
  this.callSession = callSession;
@@ -11514,7 +11609,7 @@ class Room$1 extends Emitter {
11514
11609
  * @returns {Promise<Room>}
11515
11610
  */
11516
11611
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11517
- logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11612
+ logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
11518
11613
 
11519
11614
  if (!room) {
11520
11615
  await Wazo.Phone.connect();
@@ -11527,7 +11622,7 @@ class Room$1 extends Emitter {
11527
11622
 
11528
11623
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11529
11624
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11530
- logger$3.info('room call received via WS', { callId: data.call_id });
11625
+ logger$9.info('room call received via WS', { callId: data.call_id });
11531
11626
  if (room) {
11532
11627
  room.setCallId(data.call_id);
11533
11628
  }
@@ -11535,7 +11630,7 @@ class Room$1 extends Emitter {
11535
11630
 
11536
11631
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11537
11632
  // eslint-disable-next-line no-param-reassign
11538
- room = new Room$1(callSession, extension, null, null, extra);
11633
+ room = new Room(callSession, extension, null, null, extra);
11539
11634
 
11540
11635
  // Wait for the call to be accepted
11541
11636
  await new Promise((resolve, reject) => {
@@ -11556,7 +11651,7 @@ class Room$1 extends Emitter {
11556
11651
  // Retrieve conference
11557
11652
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11558
11653
 
11559
- logger$3.info('connected to room', {
11654
+ logger$9.info('connected to room', {
11560
11655
  sourceId: conference ? conference.sourceId : null,
11561
11656
  name: conference ? conference.name : null,
11562
11657
  });
@@ -11566,7 +11661,7 @@ class Room$1 extends Emitter {
11566
11661
  room.setName(conference.name);
11567
11662
  }
11568
11663
  } else if (meeting) {
11569
- logger$3.info('Already connected to meeting', {
11664
+ logger$9.info('Already connected to meeting', {
11570
11665
  uuid: meeting.uuid,
11571
11666
  name: meeting.name,
11572
11667
  });
@@ -11579,13 +11674,13 @@ class Room$1 extends Emitter {
11579
11674
  }
11580
11675
 
11581
11676
  static disconnect() {
11582
- logger$3.info('static disconnection to room');
11677
+ logger$9.info('static disconnection to room');
11583
11678
 
11584
11679
  Wazo.Phone.disconnect();
11585
11680
  }
11586
11681
 
11587
11682
  async disconnect() {
11588
- logger$3.info('disconnection to room called');
11683
+ logger$9.info('disconnection to room called');
11589
11684
 
11590
11685
  await Wazo.Phone.hangup(this.callSession);
11591
11686
  this.callSession = null;
@@ -11605,19 +11700,19 @@ class Room$1 extends Emitter {
11605
11700
  }
11606
11701
 
11607
11702
  setSourceId(sourceId ) {
11608
- logger$3.info('set room source id', { sourceId });
11703
+ logger$9.info('set room source id', { sourceId });
11609
11704
 
11610
11705
  this.sourceId = sourceId;
11611
11706
  }
11612
11707
 
11613
11708
  setMeetingUuid(meetingUuid ) {
11614
- logger$3.info('set meeting uuid', { meetingUuid });
11709
+ logger$9.info('set meeting uuid', { meetingUuid });
11615
11710
 
11616
11711
  this.meetingUuid = meetingUuid;
11617
11712
  }
11618
11713
 
11619
11714
  setCallId(callId ) {
11620
- logger$3.info('set room call id', { callId });
11715
+ logger$9.info('set room call id', { callId });
11621
11716
 
11622
11717
  if (callId) {
11623
11718
  this.callId = callId;
@@ -11625,7 +11720,7 @@ class Room$1 extends Emitter {
11625
11720
  }
11626
11721
 
11627
11722
  setName(name ) {
11628
- logger$3.info('set room name', { name });
11723
+ logger$9.info('set room name', { name });
11629
11724
 
11630
11725
  this.name = name;
11631
11726
  }
@@ -11644,7 +11739,7 @@ class Room$1 extends Emitter {
11644
11739
  }
11645
11740
 
11646
11741
  async startScreenSharing(constraints ) {
11647
- logger$3.info('start room screen sharing', { constraints });
11742
+ logger$9.info('start room screen sharing', { constraints });
11648
11743
 
11649
11744
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11650
11745
  if (!screensharingStream) {
@@ -11658,7 +11753,7 @@ class Room$1 extends Emitter {
11658
11753
  }
11659
11754
 
11660
11755
  async stopScreenSharing(restoreLocalStream = true) {
11661
- logger$3.info('stop room screen sharing');
11756
+ logger$9.info('stop room screen sharing');
11662
11757
 
11663
11758
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11664
11759
 
@@ -11670,7 +11765,7 @@ class Room$1 extends Emitter {
11670
11765
  }
11671
11766
 
11672
11767
  turnCameraOff() {
11673
- logger$3.info('turn room camera off');
11768
+ logger$9.info('turn room camera off');
11674
11769
 
11675
11770
  Wazo.Phone.turnCameraOff(this.callSession);
11676
11771
 
@@ -11680,7 +11775,7 @@ class Room$1 extends Emitter {
11680
11775
  }
11681
11776
 
11682
11777
  turnCameraOn() {
11683
- logger$3.info('turn room camera on');
11778
+ logger$9.info('turn room camera on');
11684
11779
 
11685
11780
  Wazo.Phone.turnCameraOn(this.callSession);
11686
11781
 
@@ -11690,7 +11785,7 @@ class Room$1 extends Emitter {
11690
11785
  }
11691
11786
 
11692
11787
  mute() {
11693
- logger$3.info('mute room');
11788
+ logger$9.info('mute room');
11694
11789
 
11695
11790
  Wazo.Phone.mute(this.callSession);
11696
11791
 
@@ -11698,7 +11793,7 @@ class Room$1 extends Emitter {
11698
11793
  }
11699
11794
 
11700
11795
  unmute() {
11701
- logger$3.info('unmute room');
11796
+ logger$9.info('unmute room');
11702
11797
 
11703
11798
  Wazo.Phone.unmute(this.callSession);
11704
11799
 
@@ -11718,7 +11813,7 @@ class Room$1 extends Emitter {
11718
11813
  }
11719
11814
 
11720
11815
  hold() {
11721
- logger$3.info('hold room');
11816
+ logger$9.info('hold room');
11722
11817
 
11723
11818
  Wazo.Phone.hold(this.callSession, true);
11724
11819
 
@@ -11728,7 +11823,7 @@ class Room$1 extends Emitter {
11728
11823
  }
11729
11824
 
11730
11825
  async resume() {
11731
- logger$3.info('resume room');
11826
+ logger$9.info('resume room');
11732
11827
 
11733
11828
  const newStream = await Wazo.Phone.resume(this.callSession, true);
11734
11829
 
@@ -11756,13 +11851,13 @@ class Room$1 extends Emitter {
11756
11851
  }
11757
11852
 
11758
11853
  sendDTMF(tone ) {
11759
- logger$3.info('send room DTMF', { tone });
11854
+ logger$9.info('send room DTMF', { tone });
11760
11855
 
11761
11856
  Wazo.Phone.sendDTMF(tone, this.callSession);
11762
11857
  }
11763
11858
 
11764
11859
  async sendReinvite(newConstraints = null) {
11765
- logger$3.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11860
+ logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11766
11861
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
11767
11862
 
11768
11863
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -11821,7 +11916,7 @@ class Room$1 extends Emitter {
11821
11916
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11822
11917
 
11823
11918
  this.on(this.ON_AUDIO_STREAM, stream => {
11824
- logger$3.info('on room audio stream');
11919
+ logger$9.info('on room audio stream');
11825
11920
 
11826
11921
  this.audioStream = stream;
11827
11922
  if (!this.roomAudioElement) {
@@ -11834,7 +11929,7 @@ class Room$1 extends Emitter {
11834
11929
  });
11835
11930
 
11836
11931
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
11837
- logger$3.info('on room video stream', { streamId });
11932
+ logger$9.info('on room video stream', { streamId });
11838
11933
 
11839
11934
  this._mapMsid(sipSession.body.body);
11840
11935
 
@@ -11849,7 +11944,7 @@ class Room$1 extends Emitter {
11849
11944
  });
11850
11945
 
11851
11946
  this.on(this.ON_REMOVE_STREAM, stream => {
11852
- logger$3.info('on room remove stream');
11947
+ logger$9.info('on room remove stream');
11853
11948
 
11854
11949
  const participant = this.participants.find(someParticipant =>
11855
11950
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -11981,7 +12076,7 @@ class Room$1 extends Emitter {
11981
12076
  const requester = this._getParticipantFromCallId(origin.callId);
11982
12077
  if (requester) {
11983
12078
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
11984
- logger$3.info('trigger room requester status', { origin });
12079
+ logger$9.info('trigger room requester status', { origin });
11985
12080
  requester.triggerUpdate('REQUESTER_UPDATE');
11986
12081
  }
11987
12082
  break;
@@ -12012,24 +12107,24 @@ class Room$1 extends Emitter {
12012
12107
 
12013
12108
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
12014
12109
  if (participant.user_uuid === session.uuid) {
12015
- logger$3.info('room current user joined');
12110
+ logger$9.info('room current user joined');
12016
12111
 
12017
12112
  // Retrieve participants via an API calls
12018
12113
  const conferenceId = this.sourceId || payload.data.conference_id;
12019
12114
  let response;
12020
12115
  try {
12021
12116
  if (this.meetingUuid) {
12022
- logger$3.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12117
+ logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12023
12118
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
12024
12119
  } else {
12025
- logger$3.info('fetching conference participants', { conferenceId });
12120
+ logger$9.info('fetching conference participants', { conferenceId });
12026
12121
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
12027
12122
  }
12028
12123
  } catch (e) {
12029
- logger$3.error('room participants fetching, error', e);
12124
+ logger$9.error('room participants fetching, error', e);
12030
12125
  }
12031
12126
  if (response) {
12032
- logger$3.info('conference participants fetched', { nb: response.items.length });
12127
+ logger$9.info('conference participants fetched', { nb: response.items.length });
12033
12128
  participants = response.items.map(item => {
12034
12129
  const isMe = item.call_id === this.callId;
12035
12130
 
@@ -12056,7 +12151,7 @@ class Room$1 extends Emitter {
12056
12151
  ? new Wazo.RemoteParticipant(this, participant)
12057
12152
  : null;
12058
12153
 
12059
- logger$3.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12154
+ logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12060
12155
 
12061
12156
  if (remoteParticipant) {
12062
12157
  this.participants.push(remoteParticipant);
@@ -12221,12 +12316,12 @@ class Room$1 extends Emitter {
12221
12316
 
12222
12317
  //
12223
12318
 
12224
- const logger$2 = IssueReporter$1.loggerFor('sdk-sip-room');
12319
+ const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
12225
12320
 
12226
- class SipRoom extends Room$1 {
12321
+ class SipRoom extends Room {
12227
12322
 
12228
12323
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12229
- logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12324
+ logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
12230
12325
 
12231
12326
  if (!room) {
12232
12327
  await Wazo.Phone.connect();
@@ -12242,7 +12337,7 @@ class SipRoom extends Room$1 {
12242
12337
  room.setCallId(room.callSession.call.id);
12243
12338
  }
12244
12339
 
12245
- logger$2.info('connected to room', {
12340
+ logger$a.info('connected to room', {
12246
12341
  extension: room.extension,
12247
12342
  });
12248
12343
 
@@ -12250,7 +12345,7 @@ class SipRoom extends Room$1 {
12250
12345
  }
12251
12346
 
12252
12347
  mute() {
12253
- logger$2.info('mute sip room');
12348
+ logger$a.info('mute sip room');
12254
12349
 
12255
12350
  Wazo.Phone.mute(this.callSession, false);
12256
12351
 
@@ -12258,7 +12353,7 @@ class SipRoom extends Room$1 {
12258
12353
  }
12259
12354
 
12260
12355
  unmute() {
12261
- logger$2.info('unmute sip room');
12356
+ logger$a.info('unmute sip room');
12262
12357
 
12263
12358
  Wazo.Phone.unmute(this.callSession, false);
12264
12359
 
@@ -12525,7 +12620,7 @@ class NotificationOptions {
12525
12620
 
12526
12621
 
12527
12622
  // Represents a conference room, like `9000`.
12528
- class Room {
12623
+ class Room$1 {
12529
12624
 
12530
12625
 
12531
12626
 
@@ -12546,7 +12641,7 @@ class Room {
12546
12641
  }
12547
12642
 
12548
12643
  connect(callSession ) {
12549
- return new Room({ ...this, connectedCallSession: callSession });
12644
+ return new Room$1({ ...this, connectedCallSession: callSession });
12550
12645
  }
12551
12646
 
12552
12647
  has(callSession ) {
@@ -12555,7 +12650,7 @@ class Room {
12555
12650
 
12556
12651
  addParticipant(uuid , extension , talking = null) {
12557
12652
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12558
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12653
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12559
12654
  }
12560
12655
 
12561
12656
  return this;
@@ -12574,7 +12669,7 @@ class Room {
12574
12669
  updatedParticipants.push(participant);
12575
12670
  }
12576
12671
 
12577
- return new Room({ ...this, participants: updatedParticipants });
12672
+ return new Room$1({ ...this, participants: updatedParticipants });
12578
12673
  }
12579
12674
 
12580
12675
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12590,7 +12685,7 @@ class Room {
12590
12685
  updatedParticipants.push(participant);
12591
12686
  }
12592
12687
 
12593
- return new Room({ ...this, participants: updatedParticipants });
12688
+ return new Room$1({ ...this, participants: updatedParticipants });
12594
12689
  }
12595
12690
 
12596
12691
  hasCallWithId(id ) {
@@ -12598,18 +12693,18 @@ class Room {
12598
12693
  }
12599
12694
 
12600
12695
  disconnect() {
12601
- return new Room({ ...this, connectedCallSession: null });
12696
+ return new Room$1({ ...this, connectedCallSession: null });
12602
12697
  }
12603
12698
 
12604
12699
  removeParticipantWithUUID(uuid ) {
12605
- return new Room({
12700
+ return new Room$1({
12606
12701
  ...this,
12607
12702
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12608
12703
  });
12609
12704
  }
12610
12705
 
12611
12706
  removeParticipantWithExtension(extension ) {
12612
- return new Room({
12707
+ return new Room$1({
12613
12708
  ...this,
12614
12709
  participants: this.participants.filter(participant => participant.extension !== extension),
12615
12710
  });
@@ -12620,7 +12715,7 @@ class Room {
12620
12715
  }
12621
12716
 
12622
12717
  static newFrom(room ) {
12623
- return newFrom(room, Room);
12718
+ return newFrom(room, Room$1);
12624
12719
  }
12625
12720
  }
12626
12721
 
@@ -12927,11 +13022,11 @@ var wazoWebsocket = {
12927
13022
  resolve();
12928
13023
  };
12929
13024
 
12930
- client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
13025
+ client.on(SOCKET_EVENTS.ON_ERROR, error => {
12931
13026
  handleError(`Connection error : ${error}`);
12932
13027
  });
12933
13028
 
12934
- client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
13029
+ client.on(SOCKET_EVENTS.ON_OPEN, () => {
12935
13030
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12936
13031
  client.setOnHeartbeatTimeout(() => {
12937
13032
  handleError('No response to heartbeat');
@@ -13032,7 +13127,7 @@ var webrtc = {
13032
13127
  }),
13033
13128
  };
13034
13129
 
13035
- const parseCandidate = line => {
13130
+ const parseCandidate$1 = line => {
13036
13131
  let parts;
13037
13132
  // Parse both variants.
13038
13133
  if (line.indexOf('a=candidate:') === 0) {
@@ -13123,7 +13218,7 @@ var SymmetricNat = {
13123
13218
  }
13124
13219
 
13125
13220
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13126
- const cand = parseCandidate(e.candidate.candidate);
13221
+ const cand = parseCandidate$1(e.candidate.candidate);
13127
13222
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13128
13223
  candidates[cand.relatedPort].push(cand.port);
13129
13224
  } else if (!e.candidate) {
@@ -13191,7 +13286,7 @@ var iceIpv4 = {
13191
13286
  const rawCandidate = e.candidate.candidate;
13192
13287
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13193
13288
  hasSrflxOrRelay = true;
13194
- const candidate = parseCandidate(e.candidate.candidate);
13289
+ const candidate = parseCandidate$1(e.candidate.candidate);
13195
13290
  ips.push(candidate.ip);
13196
13291
  }
13197
13292
  } else if (!e.candidate) {
@@ -13228,7 +13323,7 @@ var checks = [
13228
13323
 
13229
13324
  //
13230
13325
 
13231
- const logger$1 = IssueReporter$1.loggerFor('engine-check');
13326
+ const logger$b = IssueReporter$1.loggerFor('engine-check');
13232
13327
 
13233
13328
  class Checker {
13234
13329
 
@@ -13246,28 +13341,28 @@ class Checker {
13246
13341
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13247
13342
  await this._addEngineVersion();
13248
13343
 
13249
- logger$1.info('Engine check starting');
13344
+ logger$b.info('Engine check starting');
13250
13345
 
13251
13346
  for (let i = 0; i < this.checks.length; i++) {
13252
13347
  const { name, check } = this.checks[i];
13253
13348
 
13254
- logger$1.info(`Checking ${name} ...`);
13349
+ logger$b.info(`Checking ${name} ...`);
13255
13350
 
13256
13351
  onCheckBegin(name);
13257
13352
  try {
13258
13353
  // eslint-disable-next-line no-await-in-loop
13259
13354
  const result = await check(this.server, this.session, this.externalAppConfig);
13260
- logger$1.info(`Checking ${name} success.`, { result });
13355
+ logger$b.info(`Checking ${name} success.`, { result });
13261
13356
 
13262
13357
  onCheckResult(name, result);
13263
13358
  } catch (e) {
13264
- logger$1.info(`Checking ${name} failure`, { message: e.message });
13359
+ logger$b.info(`Checking ${name} failure`, { message: e.message });
13265
13360
 
13266
13361
  onCheckResult(name, e);
13267
13362
  }
13268
13363
  }
13269
13364
 
13270
- logger$1.info('Engine check done.');
13365
+ logger$b.info('Engine check done.');
13271
13366
  }
13272
13367
 
13273
13368
  addCheck(check ) {
@@ -13291,7 +13386,7 @@ const Wazo = {
13291
13386
  Auth: Auth$1,
13292
13387
  Phone: Phone$1,
13293
13388
  Websocket: Websocket$1,
13294
- Room: Room$1,
13389
+ Room,
13295
13390
  SipRoom,
13296
13391
  RemoteParticipant,
13297
13392
  LocalParticipant,
@@ -13324,7 +13419,7 @@ const Wazo = {
13324
13419
  Session,
13325
13420
  Voicemail,
13326
13421
  Relocation,
13327
- ConferenceRoom: Room,
13422
+ ConferenceRoom: Room$1,
13328
13423
  CallSession,
13329
13424
  IndirectTransfer,
13330
13425
  SwitchboardCall,
@@ -13363,7 +13458,7 @@ if (global) {
13363
13458
  class InvalidSubscription extends Error {}
13364
13459
  class InvalidAuthorization extends Error {}
13365
13460
 
13366
- const logger = IssueReporter$1.loggerFor('simple-auth');
13461
+ const logger$c = IssueReporter$1.loggerFor('simple-auth');
13367
13462
 
13368
13463
  class Auth {
13369
13464
 
@@ -13398,7 +13493,7 @@ class Auth {
13398
13493
  setApiClientId(this.clientId);
13399
13494
  setRefreshExpiration(this.expiration);
13400
13495
  setOnRefreshToken((token , session ) => {
13401
- logger.info('on refresh token done', { token });
13496
+ logger$c.info('on refresh token done', { token });
13402
13497
  setApiToken(token);
13403
13498
  Wazo.Websocket.updateToken(token);
13404
13499
 
@@ -13443,7 +13538,7 @@ class Auth {
13443
13538
  const rawSession = await getApiClient().auth.authenticate(token);
13444
13539
  return this._onAuthenticated(rawSession);
13445
13540
  } catch (e) {
13446
- logger.error('on validate token error', e);
13541
+ logger$c.error('on validate token error', e);
13447
13542
  console.warn(e);
13448
13543
  return false;
13449
13544
  }