@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
@@ -875,6 +875,9 @@ class Contact {
875
875
  }
876
876
 
877
877
  static parseMany(response ) {
878
+ if (!response || !response.results) {
879
+ return [];
880
+ }
878
881
  return response.results.map(r => Contact.parse(r, response.column_types));
879
882
  }
880
883
 
@@ -1646,6 +1649,7 @@ class IssueReporter {
1646
1649
 
1647
1650
 
1648
1651
 
1652
+
1649
1653
 
1650
1654
  constructor() {
1651
1655
  addLevelsTo(this);
@@ -1657,12 +1661,17 @@ class IssueReporter {
1657
1661
  this.bufferTimeout = null;
1658
1662
  this._boundProcessBuffer = this._processBuffer.bind(this);
1659
1663
  this._boundParseLoggerBody = this._parseLoggerBody.bind(this);
1664
+ this._callback = null;
1660
1665
  }
1661
1666
 
1662
1667
  init() {
1663
1668
  this._catchConsole();
1664
1669
  }
1665
1670
 
1671
+ setCallback(cb ) {
1672
+ this._callback = cb;
1673
+ }
1674
+
1666
1675
  configureRemoteClient(configuration = { tag: 'wazo-sdk', host: null, port: null, level: null, extra: {} }) {
1667
1676
  this.remoteClientConfiguration = configuration;
1668
1677
  }
@@ -1698,6 +1707,7 @@ class IssueReporter {
1698
1707
 
1699
1708
  // Handle category label
1700
1709
  let category = null;
1710
+ let skipSendToRemote = false;
1701
1711
  let extra = {};
1702
1712
  if (args[0].indexOf(CATEGORY_PREFIX) === 0) {
1703
1713
  category = args[0].split('=')[1];
@@ -1713,6 +1723,7 @@ class IssueReporter {
1713
1723
  errorMessage: lastArg.message,
1714
1724
  errorStack: lastArg.stack,
1715
1725
  errorType: lastArg.constructor.name,
1726
+ skipSendToRemote: lastArg.skipSendToRemote,
1716
1727
  };
1717
1728
  } else {
1718
1729
  extra = lastArg;
@@ -1721,6 +1732,11 @@ class IssueReporter {
1721
1732
  args.splice(1, 1);
1722
1733
  }
1723
1734
 
1735
+ if (extra.skipSendToRemote) {
1736
+ skipSendToRemote = true;
1737
+ delete extra.skipSendToRemote;
1738
+ }
1739
+
1724
1740
  const date = moment__default['default']().format('YYYY-MM-DD HH:mm:ss.SSS');
1725
1741
  const message = args.join(', ');
1726
1742
  let consoleMessage = message;
@@ -1741,7 +1757,13 @@ class IssueReporter {
1741
1757
  const oldMethod = this.oldConsoleMethods[consoleLevel] || this.oldConsoleMethods.log;
1742
1758
  oldMethod.apply(oldMethod, [date, consoleMessage]);
1743
1759
 
1744
- this._sendToRemoteLogger(level, { date, message, category, ...extra });
1760
+ if (this._callback) {
1761
+ this._callback(level, consoleMessage);
1762
+ }
1763
+
1764
+ if (!skipSendToRemote) {
1765
+ this._sendToRemoteLogger(level, { date, message, category, ...extra });
1766
+ }
1745
1767
  }
1746
1768
 
1747
1769
  logRequest(url , options , response , start ) {
@@ -1886,7 +1908,11 @@ class IssueReporter {
1886
1908
  },
1887
1909
  // $FlowFixMe
1888
1910
  body,
1889
- }).catch(() => {
1911
+ }).catch((e ) => {
1912
+ // $FlowFixMe
1913
+ e.skipSendToRemote = true;
1914
+ this.log('error', this._makeCategory('grafana'), 'Sending log to grafana, error', e);
1915
+
1890
1916
  setTimeout(() => {
1891
1917
  if (isArray) {
1892
1918
  payload = payload.map(message => {
@@ -1933,7 +1959,7 @@ var IssueReporter$1 = new IssueReporter();
1933
1959
 
1934
1960
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1935
1961
 
1936
- const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1962
+ const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1937
1963
 
1938
1964
  // Use a function here to be able to mock it in tests
1939
1965
  const realFetch = () => {
@@ -2072,7 +2098,7 @@ class ApiRequester {
2072
2098
  };
2073
2099
 
2074
2100
  if (this.refreshTokenPromise) {
2075
- logger$c.info('A token is already refreshing, waiting ...', { url });
2101
+ logger.info('A token is already refreshing, waiting ...', { url });
2076
2102
  await this.refreshTokenPromise;
2077
2103
  }
2078
2104
 
@@ -2092,7 +2118,7 @@ class ApiRequester {
2092
2118
  return promise.then(async (err ) => {
2093
2119
  // Check if the token is still valid
2094
2120
  if (firstCall && this._checkTokenExpired(response, err)) {
2095
- logger$c.warn('token expired', { error: err.reason });
2121
+ logger.warn('token expired', { error: err.reason });
2096
2122
  // Replay the call after refreshing the token
2097
2123
  return this._replayWithNewToken(err, path, method, body, headers, parse);
2098
2124
  }
@@ -2102,7 +2128,7 @@ class ApiRequester {
2102
2128
  : exceptionClass.fromResponse(err, response.status);
2103
2129
 
2104
2130
  if (this.shouldLogErrors) {
2105
- logger$c.error('API error', error);
2131
+ logger.error('API error', error);
2106
2132
  }
2107
2133
 
2108
2134
  throw error;
@@ -2112,7 +2138,7 @@ class ApiRequester {
2112
2138
  return newParse(response, isJson);
2113
2139
  }).catch(error => {
2114
2140
  if (this.shouldLogErrors) {
2115
- logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2141
+ logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2116
2142
  }
2117
2143
 
2118
2144
  throw error;
@@ -2140,13 +2166,13 @@ class ApiRequester {
2140
2166
  ) {
2141
2167
  const isTokenNotFound = this._isTokenNotFound(err);
2142
2168
  let newPath = path;
2143
- logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2169
+ logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2144
2170
 
2145
2171
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
2146
2172
 
2147
2173
  return this.refreshTokenPromise.then(() => {
2148
2174
  this.refreshTokenPromise = null;
2149
- logger$c.info('token refreshed', { isTokenNotFound });
2175
+ logger.info('token refreshed', { isTokenNotFound });
2150
2176
  if (isTokenNotFound) {
2151
2177
  const pathParts = path.split('/');
2152
2178
  pathParts.pop();
@@ -2616,8 +2642,9 @@ class ExternalApp {
2616
2642
 
2617
2643
 
2618
2644
 
2619
-
2645
+
2620
2646
 
2647
+
2621
2648
 
2622
2649
 
2623
2650
  class Meeting {
@@ -2628,9 +2655,10 @@ class Meeting {
2628
2655
 
2629
2656
 
2630
2657
 
2631
-
2658
+
2632
2659
 
2633
2660
 
2661
+
2634
2662
 
2635
2663
  static parse(plain ) {
2636
2664
  return new Meeting({
@@ -2640,24 +2668,43 @@ class Meeting {
2640
2668
  ownerUuids: plain.owner_uuids,
2641
2669
  port: plain.port,
2642
2670
  uuid: plain.uuid,
2643
- number: plain.number,
2671
+ extension: plain.exten,
2644
2672
  persistent: plain.persistent,
2673
+ creationTime: moment__default['default'](plain.creation_time).toDate(),
2645
2674
  });
2646
2675
  }
2647
2676
 
2677
+ static parseMany(items ) {
2678
+ if (!items) {
2679
+ return [];
2680
+ }
2681
+ return items.map(plain => Meeting.parse(plain));
2682
+ }
2683
+
2648
2684
  static newFrom(meeting ) {
2649
2685
  return newFrom(meeting, Meeting);
2650
2686
  }
2651
2687
 
2652
- constructor({ uuid, name, guestSipAuthorization, ownerUuids, port, uri, number, persistent } = {}) {
2688
+ constructor({
2689
+ uuid,
2690
+ name,
2691
+ guestSipAuthorization,
2692
+ ownerUuids,
2693
+ port,
2694
+ uri,
2695
+ extension,
2696
+ persistent,
2697
+ creationTime,
2698
+ } = {}) {
2653
2699
  this.guestSipAuthorization = guestSipAuthorization;
2654
2700
  this.uri = uri;
2655
2701
  this.name = name;
2656
2702
  this.ownerUuids = ownerUuids;
2657
2703
  this.port = port;
2658
2704
  this.uuid = uuid;
2659
- this.number = number;
2705
+ this.extension = extension;
2660
2706
  this.persistent = persistent;
2707
+ this.creationTime = creationTime;
2661
2708
 
2662
2709
  // Useful to compare instead of instanceof with minified code
2663
2710
  this.type = 'Meeting';
@@ -2735,8 +2782,11 @@ var confdMethods = (client , baseUrl ) => ({
2735
2782
  }
2736
2783
  },
2737
2784
 
2738
- createMyMeeting: (name ) =>
2739
- client.post(`${baseUrl}/users/me/meetings`, { name }).then(Meeting.parse),
2785
+ getMyMeetings: () =>
2786
+ client.get(`${baseUrl}/users/me/meetings`).then(response => Meeting.parseMany(response.items)),
2787
+
2788
+ createMyMeeting: (name , persistent ) =>
2789
+ client.post(`${baseUrl}/users/me/meetings`, { name, persistent }).then(Meeting.parse),
2740
2790
 
2741
2791
  deleteMyMeeting: (meetingUuid ) =>
2742
2792
  client.delete(`${baseUrl}/users/me/meetings/${meetingUuid}`, null),
@@ -2832,6 +2882,10 @@ class ChatMessage {
2832
2882
 
2833
2883
 
2834
2884
  static parseMany(plain ) {
2885
+ if (!plain || !plain.items) {
2886
+ return [];
2887
+ }
2888
+
2835
2889
  return plain.items.map(item => ChatMessage.parse(item));
2836
2890
  }
2837
2891
 
@@ -2941,6 +2995,9 @@ class Voicemail {
2941
2995
  }
2942
2996
 
2943
2997
  static parseMany(plain ) {
2998
+ if (!plain) {
2999
+ return [];
3000
+ }
2944
3001
  const plainUnread = plain.folders.filter(folder => folder.type === 'new')[0].messages;
2945
3002
  const plainRead = plain.folders.filter(folder => folder.type === 'old')[0].messages;
2946
3003
 
@@ -3050,6 +3107,9 @@ class Call {
3050
3107
 
3051
3108
 
3052
3109
  static parseMany(plain ) {
3110
+ if (!plain) {
3111
+ return [];
3112
+ }
3053
3113
  return plain.map((plainCall ) => Call.parse(plainCall));
3054
3114
  }
3055
3115
 
@@ -3593,6 +3653,9 @@ class Recording {
3593
3653
 
3594
3654
 
3595
3655
  static parseMany(recordings = []) {
3656
+ if (!recordings) {
3657
+ return [];
3658
+ }
3596
3659
  return recordings.map(item => Recording.parse(item));
3597
3660
  }
3598
3661
 
@@ -3694,6 +3757,10 @@ class CallLog {
3694
3757
  }
3695
3758
 
3696
3759
  static parseMany(plain ) {
3760
+ if (!plain || !plain.items) {
3761
+ return [];
3762
+ }
3763
+
3697
3764
  return plain.items.map(item => CallLog.parse(item));
3698
3765
  }
3699
3766
 
@@ -3998,7 +4065,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
3998
4065
 
3999
4066
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4000
4067
 
4001
- const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4068
+ const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4002
4069
 
4003
4070
  class CTIPhone extends Emitter {
4004
4071
 
@@ -4011,7 +4078,7 @@ class CTIPhone extends Emitter {
4011
4078
 
4012
4079
  constructor(session , isMobile = false, callbackAllLines = false) {
4013
4080
  super();
4014
- logger$b.info('CTI Phone created');
4081
+ logger$1.info('CTI Phone created');
4015
4082
  this.session = session;
4016
4083
  this.isMobile = isMobile;
4017
4084
  this.callbackAllLines = callbackAllLines;
@@ -4072,7 +4139,7 @@ class CTIPhone extends Emitter {
4072
4139
  }
4073
4140
 
4074
4141
  async makeCall(number , line ) {
4075
- logger$b.info('make CTI call', { number });
4142
+ logger$1.info('make CTI call', { number });
4076
4143
 
4077
4144
  if (!number) {
4078
4145
  return null;
@@ -4095,7 +4162,7 @@ class CTIPhone extends Emitter {
4095
4162
  if (!callSession) {
4096
4163
  return Promise.resolve(null);
4097
4164
  }
4098
- logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4165
+ logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4099
4166
 
4100
4167
  if (!this.currentCall) {
4101
4168
  this.currentCall = callSession.call;
@@ -4108,7 +4175,7 @@ class CTIPhone extends Emitter {
4108
4175
  if (!callSession) {
4109
4176
  return;
4110
4177
  }
4111
- logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4178
+ logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4112
4179
 
4113
4180
  this.currentCall = undefined;
4114
4181
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4118,7 +4185,7 @@ class CTIPhone extends Emitter {
4118
4185
  if (!callSession) {
4119
4186
  return Promise.resolve(false);
4120
4187
  }
4121
- logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4188
+ logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4122
4189
 
4123
4190
  try {
4124
4191
  await CallApi.cancelCall(callSession);
@@ -4129,7 +4196,7 @@ class CTIPhone extends Emitter {
4129
4196
  this.eventEmitter.emit('onCallEnded', callSession);
4130
4197
  return true;
4131
4198
  } catch (e) {
4132
- logger$b.error('hangup CTI call, error', e);
4199
+ logger$1.error('hangup CTI call, error', e);
4133
4200
 
4134
4201
  this.eventEmitter.emit('onCallFailed', callSession);
4135
4202
  return false;
@@ -4142,7 +4209,7 @@ class CTIPhone extends Emitter {
4142
4209
  if (!callSession) {
4143
4210
  return;
4144
4211
  }
4145
- logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4212
+ logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4146
4213
 
4147
4214
  await CallApi.cancelCall(callSession);
4148
4215
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4152,7 +4219,7 @@ class CTIPhone extends Emitter {
4152
4219
  if (!callSession) {
4153
4220
  return;
4154
4221
  }
4155
- logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4222
+ logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4156
4223
 
4157
4224
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4158
4225
  }
@@ -4165,19 +4232,19 @@ class CTIPhone extends Emitter {
4165
4232
  if (!callSession) {
4166
4233
  return;
4167
4234
  }
4168
- logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4235
+ logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4169
4236
 
4170
4237
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4171
4238
  }
4172
4239
 
4173
4240
  async cancelCTIIndirectTransfer(transferId ) {
4174
- logger$b.info('cancel CTI transfer', { transferId });
4241
+ logger$1.info('cancel CTI transfer', { transferId });
4175
4242
 
4176
4243
  return CallApi.cancelCallTransfer(transferId);
4177
4244
  }
4178
4245
 
4179
4246
  async confirmCTIIndirectTransfer(transferId ) {
4180
- logger$b.info('confirm CTI transfer', { transferId });
4247
+ logger$1.info('confirm CTI transfer', { transferId });
4181
4248
 
4182
4249
  return CallApi.confirmCallTransfer(transferId);
4183
4250
  }
@@ -4186,19 +4253,19 @@ class CTIPhone extends Emitter {
4186
4253
  if (!callSession) {
4187
4254
  return;
4188
4255
  }
4189
- logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4256
+ logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4190
4257
 
4191
4258
  return CallApi.sendDTMF(callSession.callId, digits);
4192
4259
  }
4193
4260
 
4194
4261
  onConnectionMade() {
4195
- logger$b.info('on CTI connection made');
4262
+ logger$1.info('on CTI connection made');
4196
4263
 
4197
4264
  this.eventEmitter.emit('onCallAccepted');
4198
4265
  }
4199
4266
 
4200
4267
  async close() {
4201
- logger$b.info('CTI close');
4268
+ logger$1.info('CTI close');
4202
4269
 
4203
4270
  return Promise.resolve();
4204
4271
  }
@@ -4207,7 +4274,7 @@ class CTIPhone extends Emitter {
4207
4274
  if (!callSession) {
4208
4275
  return;
4209
4276
  }
4210
- logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4277
+ logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4211
4278
 
4212
4279
  return CallApi.hold(callSession.callId);
4213
4280
  }
@@ -4216,7 +4283,7 @@ class CTIPhone extends Emitter {
4216
4283
  if (!callSession) {
4217
4284
  return;
4218
4285
  }
4219
- logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4286
+ logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4220
4287
 
4221
4288
  return CallApi.resume(callSession.callId);
4222
4289
  }
@@ -4225,7 +4292,7 @@ class CTIPhone extends Emitter {
4225
4292
  if (!callSession) {
4226
4293
  return;
4227
4294
  }
4228
- logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4295
+ logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4229
4296
 
4230
4297
  return CallApi.mute(callSession.callId);
4231
4298
  }
@@ -4234,7 +4301,7 @@ class CTIPhone extends Emitter {
4234
4301
  if (!callSession) {
4235
4302
  return;
4236
4303
  }
4237
- logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4304
+ logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4238
4305
 
4239
4306
  return CallApi.unmute(callSession.callId);
4240
4307
  }
@@ -4263,6 +4330,10 @@ class CTIPhone extends Emitter {
4263
4330
  return false;
4264
4331
  }
4265
4332
 
4333
+ hasAVideoTrack() {
4334
+ return false;
4335
+ }
4336
+
4266
4337
  getLocalStreamForCall() {
4267
4338
  return null;
4268
4339
  }
@@ -4656,6 +4727,9 @@ class ChatRoom {
4656
4727
 
4657
4728
 
4658
4729
  static parseMany(plain ) {
4730
+ if (!plain || !plain.items) {
4731
+ return [];
4732
+ }
4659
4733
  return plain.items.map(item => ChatRoom.parse(item));
4660
4734
  }
4661
4735
 
@@ -5236,7 +5310,7 @@ const AGENTD_VERSION = '1.0';
5236
5310
  const WEBHOOKD_VERSION = '1.0';
5237
5311
  const AMID_VERSION = '1.0';
5238
5312
 
5239
- const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5313
+ const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5240
5314
 
5241
5315
  class ApiClient {
5242
5316
 
@@ -5288,12 +5362,12 @@ class ApiClient {
5288
5362
  }
5289
5363
 
5290
5364
  async forceRefreshToken() {
5291
- logger$a.info('forcing refresh token, calling callback');
5365
+ logger$2.info('forcing refresh token, calling callback');
5292
5366
  return this.refreshTokenCallback();
5293
5367
  }
5294
5368
 
5295
5369
  async refreshTokenCallback() {
5296
- logger$a.info('refresh token callback called', {
5370
+ logger$2.info('refresh token callback called', {
5297
5371
  refreshToken: this.refreshToken,
5298
5372
  refreshBackend: this.refreshBackend,
5299
5373
  refreshExpiration: this.refreshExpiration,
@@ -5311,7 +5385,7 @@ class ApiClient {
5311
5385
  this.isMobile,
5312
5386
  );
5313
5387
 
5314
- logger$a.info('token refreshed', { token: session.token });
5388
+ logger$2.info('token refreshed', { token: session.token });
5315
5389
 
5316
5390
  if (this.onRefreshToken) {
5317
5391
  this.onRefreshToken(session.token, session);
@@ -5624,7 +5698,7 @@ class AdHocAPIConference {
5624
5698
 
5625
5699
  /* */
5626
5700
 
5627
- const parseCandidate$1 = (candidate ) => {
5701
+ const parseCandidate = (candidate ) => {
5628
5702
  if (!candidate) {
5629
5703
  return null;
5630
5704
  }
@@ -5637,10 +5711,6 @@ const getSrflxOrRelay = (candidates ) =>
5637
5711
  candidates
5638
5712
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5639
5713
 
5640
- const areCandidateValid = (candidates ) =>
5641
- getSrflxOrRelay(candidates)
5642
- .length > 0;
5643
-
5644
5714
  const getVideoDirection = (sdp ) => {
5645
5715
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5646
5716
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5693,8 +5763,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5693
5763
  /* global RTCSessionDescriptionInit, navigator */
5694
5764
 
5695
5765
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5696
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5697
- const WAIT_FOR_ICE_TIMEOUT = 500;
5698
5766
 
5699
5767
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5700
5768
  const wazoMediaStreamFactory = (constraints ) => {
@@ -5784,7 +5852,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5784
5852
  this.peerConnectionDelegate.onicecandidate = event => {
5785
5853
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5786
5854
  if (event.candidate) {
5787
- this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5855
+ this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5788
5856
  }
5789
5857
  };
5790
5858
 
@@ -5884,38 +5952,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5884
5952
  this._peerConnection = undefined;
5885
5953
  }
5886
5954
 
5887
- async _waitForValidGatheredIce() {
5888
- let tries = 0;
5889
-
5890
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
5891
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
5892
- tries,
5893
- max: MAX_WAIT_FOR_ICE_TRIES,
5894
- });
5895
-
5896
- tries++;
5897
-
5898
- // eslint-disable-next-line no-await-in-loop
5899
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
5900
- }
5901
-
5902
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
5903
- const errorMsg = 'No valid candidates found, can\'t answer the call';
5904
- const error = new Error(errorMsg);
5905
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
5906
-
5907
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
5908
- this.eventEmitter.emit('error', error);
5909
-
5910
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5911
- }
5912
-
5913
- // eslint-disable-next-line
5914
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
5915
-
5916
- return this.getLocalSessionDescription();
5917
- }
5918
-
5919
5955
  // Overridden to send `inactive` in conference
5920
5956
  updateDirection(options , isConference = false,
5921
5957
  audioOnly = false) {
@@ -6280,7 +6316,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6280
6316
  const SEND_STATS_DELAY = 5000;
6281
6317
 
6282
6318
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6283
- const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6319
+ const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6284
6320
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6285
6321
 
6286
6322
  // events
@@ -6294,14 +6330,14 @@ const TRANSPORT_ERROR = 'transportError';
6294
6330
  const MESSAGE = 'message';
6295
6331
  const ACCEPTED = 'accepted';
6296
6332
  const REJECTED = 'rejected';
6297
- const ON_TRACK$1 = 'onTrack';
6298
- const ON_REINVITE$1 = 'reinvite';
6333
+ const ON_TRACK = 'onTrack';
6334
+ const ON_REINVITE = 'reinvite';
6299
6335
  const ON_ERROR = 'onError';
6300
6336
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6301
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
6302
- const ON_DISCONNECTED$1 = 'onDisconnected';
6337
+ const ON_NETWORK_STATS = 'onNetworkStats';
6338
+ const ON_DISCONNECTED = 'onDisconnected';
6303
6339
 
6304
- const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6340
+ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6305
6341
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6306
6342
  class CanceledCallError extends Error {}
6307
6343
 
@@ -6437,12 +6473,12 @@ class WebRTCClient extends Emitter {
6437
6473
  this.MESSAGE = MESSAGE;
6438
6474
  this.ACCEPTED = ACCEPTED;
6439
6475
  this.REJECTED = REJECTED;
6440
- this.ON_TRACK = ON_TRACK$1;
6441
- this.ON_REINVITE = ON_REINVITE$1;
6476
+ this.ON_TRACK = ON_TRACK;
6477
+ this.ON_REINVITE = ON_REINVITE;
6442
6478
  this.ON_ERROR = ON_ERROR;
6443
6479
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6444
- this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6445
- this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6480
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6481
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
6446
6482
  }
6447
6483
 
6448
6484
  configureMedia(media ) {
@@ -6459,13 +6495,13 @@ class WebRTCClient extends Emitter {
6459
6495
 
6460
6496
  createUserAgent(configOverrides ) {
6461
6497
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6462
- logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6498
+ logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6463
6499
 
6464
6500
  webRTCConfiguration.delegate = {
6465
6501
  onConnect: this.onConnect.bind(this),
6466
6502
  onDisconnect: this.onDisconnect.bind(this),
6467
6503
  onInvite: (invitation ) => {
6468
- logger$9.info('sdk webrtc on invite', {
6504
+ logger$3.info('sdk webrtc on invite', {
6469
6505
  method: 'delegate.onInvite',
6470
6506
  id: invitation.id,
6471
6507
  remoteURI: invitation.remoteURI,
@@ -6508,7 +6544,7 @@ class WebRTCClient extends Emitter {
6508
6544
  }
6509
6545
 
6510
6546
  onConnect() {
6511
- logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6547
+ logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6512
6548
  this.eventEmitter.emit(CONNECTED);
6513
6549
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6514
6550
  this.registerer.waitingToggle(false);
@@ -6517,7 +6553,7 @@ class WebRTCClient extends Emitter {
6517
6553
  }
6518
6554
 
6519
6555
  async onDisconnect(error ) {
6520
- logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6556
+ logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6521
6557
  this.connectionPromise = null;
6522
6558
  // The UA will attempt to reconnect automatically when an error occurred
6523
6559
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6542,37 +6578,37 @@ class WebRTCClient extends Emitter {
6542
6578
  };
6543
6579
 
6544
6580
  if (this.skipRegister) {
6545
- logger$9.info('sdk webrtc skip register...', logInfo);
6581
+ logger$3.info('sdk webrtc skip register...', logInfo);
6546
6582
  return Promise.resolve();
6547
6583
  }
6548
6584
 
6549
- logger$9.info('sdk webrtc registering...', logInfo);
6585
+ logger$3.info('sdk webrtc registering...', logInfo);
6550
6586
 
6551
6587
  if (!this.userAgent) {
6552
- logger$9.info('sdk webrtc recreating User Agent');
6588
+ logger$3.info('sdk webrtc recreating User Agent');
6553
6589
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6554
6590
  }
6555
6591
  if (!this.userAgent || this.isRegistered()) {
6556
- logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6592
+ logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6557
6593
  return Promise.resolve();
6558
6594
  }
6559
6595
 
6560
6596
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6561
- logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6597
+ logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6562
6598
  return Promise.resolve();
6563
6599
  }
6564
6600
 
6565
6601
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6566
6602
 
6567
6603
  const onRegisterFailed = () => {
6568
- logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6604
+ logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6569
6605
  this.connectionPromise = null;
6570
6606
  if (this.registerer && this.registerer.waiting) {
6571
6607
  this.registerer.waitingToggle(false);
6572
6608
  }
6573
6609
 
6574
6610
  if (tries <= MAX_REGISTER_TRIES) {
6575
- logger$9.info('sdk webrtc registering, retrying...', { tries });
6611
+ logger$3.info('sdk webrtc registering, retrying...', { tries });
6576
6612
  setTimeout(() => this.register(tries + 1), 300);
6577
6613
  }
6578
6614
  };
@@ -6581,18 +6617,18 @@ class WebRTCClient extends Emitter {
6581
6617
  // Avoid race condition with the close method called just before register and setting userAgent to null
6582
6618
  // during the resolution of the primise.
6583
6619
  if (!this.userAgent) {
6584
- logger$9.info('sdk webrtc recreating User Agent after connection');
6620
+ logger$3.info('sdk webrtc recreating User Agent after connection');
6585
6621
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6586
6622
  }
6587
6623
 
6588
- logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6624
+ logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6589
6625
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6590
6626
  this.connectionPromise = null;
6591
6627
  this._monkeyPatchRegisterer(this.registerer);
6592
6628
 
6593
6629
  // Bind registerer events
6594
6630
  this.registerer.stateChange.addListener(newState => {
6595
- logger$9.info('sdk webrtc registering, state changed', { newState });
6631
+ logger$3.info('sdk webrtc registering, state changed', { newState });
6596
6632
 
6597
6633
  if (newState === registererState.RegistererState.Registered && this.registerer
6598
6634
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6605,7 +6641,7 @@ class WebRTCClient extends Emitter {
6605
6641
  const options = {
6606
6642
  requestDelegate: {
6607
6643
  onReject: response => {
6608
- logger$9.error('sdk webrtc registering, rejected', { response });
6644
+ logger$3.error('sdk webrtc registering, rejected', { response });
6609
6645
 
6610
6646
  onRegisterFailed();
6611
6647
  },
@@ -6613,13 +6649,13 @@ class WebRTCClient extends Emitter {
6613
6649
  };
6614
6650
 
6615
6651
  return this.registerer.register(options).catch((e) => {
6616
- logger$9.error('sdk webrtc registering, error', e);
6652
+ logger$3.error('sdk webrtc registering, error', e);
6617
6653
 
6618
6654
  this.eventEmitter.emit(REGISTRATION_FAILED);
6619
6655
  return e;
6620
6656
  });
6621
6657
  }).catch(error => {
6622
- logger$9.error('sdk webrtc registering, transport error', error);
6658
+ logger$3.error('sdk webrtc registering, transport error', error);
6623
6659
  onRegisterFailed();
6624
6660
  });
6625
6661
  }
@@ -6648,21 +6684,21 @@ class WebRTCClient extends Emitter {
6648
6684
  }
6649
6685
 
6650
6686
  unregister() {
6651
- logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6687
+ logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6652
6688
  if (!this.registerer) {
6653
6689
  return Promise.resolve();
6654
6690
  }
6655
6691
 
6656
6692
  try {
6657
6693
  return this.registerer.unregister().then(() => {
6658
- logger$9.info('sdk webrtc unregistered');
6694
+ logger$3.info('sdk webrtc unregistered');
6659
6695
  this._cleanupRegister();
6660
6696
  }).catch(e => {
6661
- logger$9.error('sdk webrtc unregistering, promise error', e);
6697
+ logger$3.error('sdk webrtc unregistering, promise error', e);
6662
6698
  this._cleanupRegister();
6663
6699
  });
6664
6700
  } catch (e) {
6665
- logger$9.error('sdk webrtc unregistering, error', e);
6701
+ logger$3.error('sdk webrtc unregistering, error', e);
6666
6702
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6667
6703
  // error when the registerer is in a bad state
6668
6704
  this._cleanupRegister();
@@ -6670,7 +6706,7 @@ class WebRTCClient extends Emitter {
6670
6706
  }
6671
6707
 
6672
6708
  stop() {
6673
- logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6709
+ logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6674
6710
  if (!this.userAgent) {
6675
6711
  return Promise.resolve();
6676
6712
  }
@@ -6678,12 +6714,12 @@ class WebRTCClient extends Emitter {
6678
6714
  return this.userAgent.stop().then(() => {
6679
6715
  return this._cleanupRegister();
6680
6716
  }).catch(e => {
6681
- logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6717
+ logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6682
6718
  });
6683
6719
  }
6684
6720
 
6685
6721
  call(number , enableVideo , audioOnly = false, conference = false) {
6686
- logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6722
+ logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6687
6723
  const inviterOptions = {
6688
6724
  sessionDescriptionHandlerOptionsReInvite: {
6689
6725
  conference,
@@ -6708,11 +6744,13 @@ class WebRTCClient extends Emitter {
6708
6744
  const inviteOptions = {
6709
6745
  requestDelegate: {
6710
6746
  onAccept: (response ) => {
6711
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
6747
+ if (session.sessionDescriptionHandler.peerConnection) {
6748
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
6749
+ }
6712
6750
  this._onAccepted(session, response.session, true);
6713
6751
  },
6714
6752
  onReject: (response ) => {
6715
- logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6753
+ logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6716
6754
  this._stopSendingStats(session);
6717
6755
  this.stopNetworkMonitoring(session);
6718
6756
 
@@ -6735,11 +6773,11 @@ class WebRTCClient extends Emitter {
6735
6773
  }
6736
6774
 
6737
6775
  answer(session , enableVideo ) {
6738
- logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6776
+ logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6739
6777
 
6740
6778
  if (!session || !session.accept) {
6741
6779
  const error = 'No session to answer, or not an invitation';
6742
- logger$9.warn(error);
6780
+ logger$3.warn(error);
6743
6781
  return Promise.reject(new Error(error));
6744
6782
  }
6745
6783
  const options = {
@@ -6749,15 +6787,15 @@ class WebRTCClient extends Emitter {
6749
6787
  return session.accept(options).then(() => {
6750
6788
  if (session.isCanceled) {
6751
6789
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6752
- logger$9.error(message, { id: session.id });
6790
+ logger$3.error(message, { id: session.id });
6753
6791
  this.onCallEnded(session);
6754
6792
 
6755
6793
  throw new CanceledCallError(message);
6756
6794
  }
6757
- logger$9.info('sdk webrtc answer, accepted.');
6795
+ logger$3.info('sdk webrtc answer, accepted.');
6758
6796
  this._onAccepted(session);
6759
6797
  }).catch(e => {
6760
- logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6798
+ logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6761
6799
 
6762
6800
  throw e;
6763
6801
  });
@@ -6765,7 +6803,7 @@ class WebRTCClient extends Emitter {
6765
6803
 
6766
6804
  hangup(session ) {
6767
6805
  const { state, id } = session;
6768
- logger$9.info('sdk webrtc hangup call', { id, state });
6806
+ logger$3.info('sdk webrtc hangup call', { id, state });
6769
6807
 
6770
6808
  try {
6771
6809
  this._stopSendingStats(session);
@@ -6794,7 +6832,7 @@ class WebRTCClient extends Emitter {
6794
6832
 
6795
6833
  return bye();
6796
6834
  } catch (error) {
6797
- logger$9.warn('sdk webrtc hangup, error', error);
6835
+ logger$3.warn('sdk webrtc hangup, error', error);
6798
6836
  }
6799
6837
 
6800
6838
  return null;
@@ -6812,7 +6850,7 @@ class WebRTCClient extends Emitter {
6812
6850
  // Fetch and emit an event at `interval` with session network stats
6813
6851
  startNetworkMonitoring(session , interval = 1000) {
6814
6852
  const sessionId = this.getSipSessionId(session);
6815
- logger$9.info('starting network inspection', { id: sessionId });
6853
+ logger$3.info('starting network inspection', { id: sessionId });
6816
6854
 
6817
6855
  this.sessionNetworkStats[sessionId] = [];
6818
6856
 
@@ -6822,7 +6860,7 @@ class WebRTCClient extends Emitter {
6822
6860
  stopNetworkMonitoring(session ) {
6823
6861
  const sessionId = this.getSipSessionId(session);
6824
6862
  const exists = sessionId in this.networkMonitoringInterval;
6825
- logger$9.info('stopping network inspection', { id: sessionId, exists });
6863
+ logger$3.info('stopping network inspection', { id: sessionId, exists });
6826
6864
 
6827
6865
  if (exists) {
6828
6866
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6832,17 +6870,17 @@ class WebRTCClient extends Emitter {
6832
6870
  }
6833
6871
 
6834
6872
  reject(session ) {
6835
- logger$9.info('sdk webrtc reject call', { id: session.id });
6873
+ logger$3.info('sdk webrtc reject call', { id: session.id });
6836
6874
 
6837
6875
  try {
6838
6876
  return session.reject ? session.reject() : session.cancel();
6839
6877
  } catch (e) {
6840
- logger$9.warn('Error when rejecting call', e.message, e.stack);
6878
+ logger$3.warn('Error when rejecting call', e.message, e.stack);
6841
6879
  }
6842
6880
  }
6843
6881
 
6844
6882
  async close() {
6845
- logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6883
+ logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6846
6884
  this._cleanupMedia();
6847
6885
  this.connectionPromise = null;
6848
6886
 
@@ -6873,7 +6911,7 @@ class WebRTCClient extends Emitter {
6873
6911
  // eg: "INVITE not rejectable in state Completed"
6874
6912
  }
6875
6913
  this.userAgent = null;
6876
- logger$9.info('sdk webrtc client closed');
6914
+ logger$3.info('sdk webrtc client closed');
6877
6915
  }
6878
6916
 
6879
6917
  getNumber(session ) {
@@ -6886,13 +6924,13 @@ class WebRTCClient extends Emitter {
6886
6924
  }
6887
6925
 
6888
6926
  mute(session ) {
6889
- logger$9.info('sdk webrtc mute', { id: session.id });
6927
+ logger$3.info('sdk webrtc mute', { id: session.id });
6890
6928
 
6891
6929
  this._toggleAudio(session, true);
6892
6930
  }
6893
6931
 
6894
6932
  unmute(session ) {
6895
- logger$9.info('sdk webrtc unmute', { id: session.id });
6933
+ logger$3.info('sdk webrtc unmute', { id: session.id });
6896
6934
 
6897
6935
  this._toggleAudio(session, false);
6898
6936
  }
@@ -6932,13 +6970,13 @@ class WebRTCClient extends Emitter {
6932
6970
  }
6933
6971
 
6934
6972
  toggleCameraOn(session ) {
6935
- logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6973
+ logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6936
6974
 
6937
6975
  this._toggleVideo(session, false);
6938
6976
  }
6939
6977
 
6940
6978
  toggleCameraOff(session ) {
6941
- logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6979
+ logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6942
6980
 
6943
6981
  this._toggleVideo(session, true);
6944
6982
  }
@@ -6947,7 +6985,7 @@ class WebRTCClient extends Emitter {
6947
6985
  const sessionId = this.getSipSessionId(session);
6948
6986
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6949
6987
 
6950
- logger$9.info('sdk webrtc hold', {
6988
+ logger$3.info('sdk webrtc hold', {
6951
6989
  sessionId,
6952
6990
  keys: Object.keys(this.heldSessions),
6953
6991
  pendingReinvite: !!session.pendingReinvite,
@@ -6996,7 +7034,7 @@ class WebRTCClient extends Emitter {
6996
7034
  const sessionId = this.getSipSessionId(session);
6997
7035
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
6998
7036
 
6999
- logger$9.info('sdk webrtc unhold', {
7037
+ logger$3.info('sdk webrtc unhold', {
7000
7038
  sessionId,
7001
7039
  keys: Object.keys(this.heldSessions),
7002
7040
  pendingReinvite: !!session.pendingReinvite,
@@ -7144,7 +7182,7 @@ class WebRTCClient extends Emitter {
7144
7182
  if (!session.sessionDescriptionHandler) {
7145
7183
  return;
7146
7184
  }
7147
- logger$9.info('Sending DTMF', {
7185
+ logger$3.info('Sending DTMF', {
7148
7186
  id: this.getSipSessionId(session),
7149
7187
  tone,
7150
7188
  });
@@ -7160,7 +7198,7 @@ class WebRTCClient extends Emitter {
7160
7198
  transfer(session , target ) {
7161
7199
  this.hold(session);
7162
7200
 
7163
- logger$9.info('Transfering a session', {
7201
+ logger$3.info('Transfering a session', {
7164
7202
  id: this.getSipSessionId(session),
7165
7203
  target,
7166
7204
  });
@@ -7182,17 +7220,17 @@ class WebRTCClient extends Emitter {
7182
7220
  atxfer(session ) {
7183
7221
  this.hold(session);
7184
7222
 
7185
- logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7223
+ logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7186
7224
 
7187
7225
  const result = {
7188
7226
  newSession: null,
7189
7227
  init: async (target ) => {
7190
- logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7228
+ logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7191
7229
 
7192
7230
  result.newSession = await this.call(target);
7193
7231
  },
7194
7232
  complete: () => {
7195
- logger$9.info('webrtc transfer completed', {
7233
+ logger$3.info('webrtc transfer completed', {
7196
7234
  id: this.getSipSessionId(session),
7197
7235
  referId: this.getSipSessionId(result.newSession),
7198
7236
  });
@@ -7213,7 +7251,7 @@ class WebRTCClient extends Emitter {
7213
7251
  return;
7214
7252
  }
7215
7253
 
7216
- logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7254
+ logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7217
7255
 
7218
7256
  try {
7219
7257
  sipSession.message({
@@ -7255,7 +7293,7 @@ class WebRTCClient extends Emitter {
7255
7293
  }
7256
7294
 
7257
7295
  changeAudioOutputVolume(volume ) {
7258
- logger$9.info('Changing audio output volume', { volume });
7296
+ logger$3.info('Changing audio output volume', { volume });
7259
7297
 
7260
7298
  Object.values(this.audioElements).forEach(audioElement => {
7261
7299
  if (audioElement instanceof HTMLAudioElement) {
@@ -7267,7 +7305,7 @@ class WebRTCClient extends Emitter {
7267
7305
  }
7268
7306
 
7269
7307
  changeAudioOutputDevice(id ) {
7270
- logger$9.info('Changing audio output device', { id });
7308
+ logger$3.info('Changing audio output device', { id });
7271
7309
 
7272
7310
  Object.values(this.audioElements).forEach(audioElement => {
7273
7311
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7284,7 +7322,7 @@ class WebRTCClient extends Emitter {
7284
7322
 
7285
7323
  changeAudioInputDevice(id , session ) {
7286
7324
  const currentId = this.getAudioDeviceId();
7287
- logger$9.info('setting audio input device', { id, currentId, session: !!session });
7325
+ logger$3.info('setting audio input device', { id, currentId, session: !!session });
7288
7326
 
7289
7327
  if (id === currentId) {
7290
7328
  return null;
@@ -7330,7 +7368,7 @@ class WebRTCClient extends Emitter {
7330
7368
 
7331
7369
  setVideoInputDevice(id ) {
7332
7370
  const currentId = this.getVideoDeviceId();
7333
- logger$9.info('setting video input device', { id, currentId });
7371
+ logger$3.info('setting video input device', { id, currentId });
7334
7372
 
7335
7373
  if (id === currentId) {
7336
7374
  return null;
@@ -7355,7 +7393,7 @@ class WebRTCClient extends Emitter {
7355
7393
  const sessionId = this.getSipSessionId(session);
7356
7394
  const localStream = this.getLocalStream(sessionId);
7357
7395
 
7358
- logger$9.info('changing video input device', { id, sessionId });
7396
+ logger$3.info('changing video input device', { id, sessionId });
7359
7397
 
7360
7398
  // Release old video stream
7361
7399
  if (localStream) {
@@ -7423,7 +7461,7 @@ class WebRTCClient extends Emitter {
7423
7461
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7424
7462
  const desktop = newConstraints && newConstraints.desktop;
7425
7463
 
7426
- logger$9.info('Sending reinvite', {
7464
+ logger$3.info('Sending reinvite', {
7427
7465
  id: this.getSipSessionId(sipSession),
7428
7466
  newConstraints,
7429
7467
  conference,
@@ -7461,7 +7499,7 @@ class WebRTCClient extends Emitter {
7461
7499
  sipSession.incomingInviteRequest.message.body = response.message.body;
7462
7500
  }
7463
7501
 
7464
- logger$9.info('on re-INVITE accepted', {
7502
+ logger$3.info('on re-INVITE accepted', {
7465
7503
  id: this.getSipSessionId(sipSession),
7466
7504
  wasMuted,
7467
7505
  shouldDoScreenSharing,
@@ -7479,7 +7517,7 @@ class WebRTCClient extends Emitter {
7479
7517
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7480
7518
  }
7481
7519
 
7482
- return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7520
+ return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7483
7521
  },
7484
7522
  },
7485
7523
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7580,6 +7618,16 @@ class WebRTCClient extends Emitter {
7580
7618
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7581
7619
  }
7582
7620
 
7621
+ // Useful in a react-native environment when remoteMediaStream is not updated
7622
+ getRemoteVideoStreamFromPc(sessionId ) {
7623
+ const pc = this.getPeerConnection(sessionId);
7624
+ if (!pc) {
7625
+ return null;
7626
+ }
7627
+
7628
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7629
+ }
7630
+
7583
7631
  hasVideo(sessionId ) {
7584
7632
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7585
7633
  }
@@ -7626,7 +7674,7 @@ class WebRTCClient extends Emitter {
7626
7674
  }
7627
7675
 
7628
7676
  startHeartbeat() {
7629
- logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7677
+ logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7630
7678
  if (!this.userAgent) {
7631
7679
  this.heartbeat.stop();
7632
7680
  return;
@@ -7639,7 +7687,7 @@ class WebRTCClient extends Emitter {
7639
7687
  }
7640
7688
 
7641
7689
  stopHeartbeat() {
7642
- logger$9.info('sdk webrtc stop heartbeat');
7690
+ logger$3.info('sdk webrtc stop heartbeat');
7643
7691
  this.heartbeat.stop();
7644
7692
  }
7645
7693
 
@@ -7660,7 +7708,7 @@ class WebRTCClient extends Emitter {
7660
7708
  }
7661
7709
 
7662
7710
  attemptReconnection() {
7663
- logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7711
+ logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7664
7712
  if (!this.userAgent) {
7665
7713
  return;
7666
7714
  }
@@ -7685,7 +7733,7 @@ class WebRTCClient extends Emitter {
7685
7733
  return;
7686
7734
  }
7687
7735
 
7688
- logger$9.info('setting local media stream', {
7736
+ logger$3.info('setting local media stream', {
7689
7737
  sipSessionId,
7690
7738
  tracks: newStream ? newStream.getTracks() : null,
7691
7739
  });
@@ -7702,7 +7750,7 @@ class WebRTCClient extends Emitter {
7702
7750
 
7703
7751
  const oldStream = this.getLocalStream(sipSessionId);
7704
7752
 
7705
- logger$9.info('updating local stream', {
7753
+ logger$3.info('updating local stream', {
7706
7754
  sipSessionId,
7707
7755
  oldStream: !!oldStream,
7708
7756
  tracks: newStream.getTracks(),
@@ -7722,7 +7770,7 @@ class WebRTCClient extends Emitter {
7722
7770
  const remoteStream = this.getRemoteStream(sessionId);
7723
7771
  const pc = this.getPeerConnection(sessionId);
7724
7772
 
7725
- logger$9.info('Updating remote stream', {
7773
+ logger$3.info('Updating remote stream', {
7726
7774
  sessionId,
7727
7775
  tracks: remoteStream ? remoteStream.getTracks() : null,
7728
7776
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7748,7 +7796,7 @@ class WebRTCClient extends Emitter {
7748
7796
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7749
7797
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7750
7798
 
7751
- logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7799
+ logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7752
7800
 
7753
7801
  return {
7754
7802
  constraints: {
@@ -7797,7 +7845,7 @@ class WebRTCClient extends Emitter {
7797
7845
  }
7798
7846
 
7799
7847
  _onTransportError() {
7800
- logger$9.error('on transport error');
7848
+ logger$3.error('on transport error');
7801
7849
  this.eventEmitter.emit(TRANSPORT_ERROR);
7802
7850
  this.attemptReconnection();
7803
7851
  }
@@ -7806,7 +7854,7 @@ class WebRTCClient extends Emitter {
7806
7854
  const body = message && typeof message === 'object' ? message.data : message;
7807
7855
  if (body && body.indexOf('200 OK') !== -1) {
7808
7856
  if (this.hasHeartbeat()) {
7809
- logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7857
+ logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7810
7858
 
7811
7859
  this.heartbeat.onHeartbeat();
7812
7860
  if (this.heartbeatCb) {
@@ -7817,7 +7865,7 @@ class WebRTCClient extends Emitter {
7817
7865
  }
7818
7866
 
7819
7867
  async _onHeartbeatTimeout() {
7820
- logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7868
+ logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7821
7869
 
7822
7870
  if (this.heartbeatTimeoutCb) {
7823
7871
  this.heartbeatTimeoutCb();
@@ -7829,7 +7877,7 @@ class WebRTCClient extends Emitter {
7829
7877
  try {
7830
7878
  await this.userAgent.transport.disconnect();
7831
7879
  } catch (e) {
7832
- logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7880
+ logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7833
7881
  }
7834
7882
  }
7835
7883
 
@@ -7862,31 +7910,31 @@ class WebRTCClient extends Emitter {
7862
7910
  }
7863
7911
 
7864
7912
  _connectIfNeeded() {
7865
- logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7913
+ logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7866
7914
  if (!this.userAgent) {
7867
- logger$9.info('need to recreate User Agent');
7915
+ logger$3.info('need to recreate User Agent');
7868
7916
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7869
7917
  }
7870
7918
 
7871
7919
  if (this.isConnected()) {
7872
- logger$9.info('webrtc sdk, already connected');
7920
+ logger$3.info('webrtc sdk, already connected');
7873
7921
  return Promise.resolve();
7874
7922
  }
7875
7923
 
7876
7924
  if (this.isConnecting()) {
7877
- logger$9.info('webrtc sdk, already connecting...');
7925
+ logger$3.info('webrtc sdk, already connecting...');
7878
7926
 
7879
7927
  this.connectionPromise = this.userAgent.transport.connectPromise;
7880
7928
  return this.connectionPromise;
7881
7929
  }
7882
7930
 
7883
7931
  if (this.connectionPromise) {
7884
- logger$9.info('webrtc sdk, connection promise connecting...');
7932
+ logger$3.info('webrtc sdk, connection promise connecting...');
7885
7933
  // $FlowFixMe
7886
7934
  return this.connectionPromise;
7887
7935
  }
7888
7936
 
7889
- logger$9.info('WebRTC UA needs to connect');
7937
+ logger$3.info('WebRTC UA needs to connect');
7890
7938
 
7891
7939
  // Force UA to reconnect
7892
7940
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8011,7 +8059,7 @@ class WebRTCClient extends Emitter {
8011
8059
 
8012
8060
  sdh.peerConnectionDelegate = {
8013
8061
  onicecandidateerror: (error ) => {
8014
- logger$9.error('on icecandidate error', {
8062
+ logger$3.error('on icecandidate error', {
8015
8063
  address: error.address,
8016
8064
  port: error.port,
8017
8065
  errorCode: error.errorCode,
@@ -8040,7 +8088,7 @@ class WebRTCClient extends Emitter {
8040
8088
  updatedNumber = session.assertedIdentity.uri.normal.user;
8041
8089
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8042
8090
  }
8043
- logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8091
+ logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8044
8092
 
8045
8093
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8046
8094
 
@@ -8056,12 +8104,12 @@ class WebRTCClient extends Emitter {
8056
8104
 
8057
8105
  this._setupMedias(session);
8058
8106
 
8059
- return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8107
+ return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8060
8108
  };
8061
8109
  }
8062
8110
 
8063
8111
  _onAccepted(session , sessionDialog , withEvent = true) {
8064
- logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8112
+ logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8065
8113
 
8066
8114
  this.storeSipSession(session);
8067
8115
 
@@ -8073,14 +8121,14 @@ class WebRTCClient extends Emitter {
8073
8121
  const onTrack = (event ) => {
8074
8122
  const isAudioOnly = this._isAudioOnly(session);
8075
8123
  const { kind, label, readyState, id, muted } = event.track;
8076
- logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8124
+ logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8077
8125
 
8078
8126
  // Stop video track in audio only mode
8079
8127
  if (isAudioOnly && kind === 'video') {
8080
8128
  event.track.stop();
8081
8129
  }
8082
8130
 
8083
- this.eventEmitter.emit(ON_TRACK$1, session, event);
8131
+ this.eventEmitter.emit(ON_TRACK, session, event);
8084
8132
  };
8085
8133
 
8086
8134
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8090,8 +8138,9 @@ class WebRTCClient extends Emitter {
8090
8138
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8091
8139
 
8092
8140
  pc.oniceconnectionstatechange = () => {
8141
+ logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
8093
8142
  if (pc.iceConnectionState === 'disconnected') {
8094
- this.eventEmitter.emit(ON_DISCONNECTED$1);
8143
+ this.eventEmitter.emit(ON_DISCONNECTED);
8095
8144
  }
8096
8145
  };
8097
8146
 
@@ -8262,10 +8311,10 @@ class WebRTCClient extends Emitter {
8262
8311
 
8263
8312
  _stopSendingStats(session ) {
8264
8313
  const sessionId = this.getSipSessionId(session);
8265
- logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8314
+ logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8266
8315
 
8267
8316
  if (sessionId in this.statsIntervals) {
8268
- logger$9.trace('Stop sending stats for call', { sessionId });
8317
+ logger$3.trace('Stop sending stats for call', { sessionId });
8269
8318
  this.statsIntervals[sessionId]();
8270
8319
  delete this.statsIntervals[sessionId];
8271
8320
  }
@@ -8281,7 +8330,7 @@ class WebRTCClient extends Emitter {
8281
8330
  try {
8282
8331
  await this.userAgent.transport.disconnect();
8283
8332
  } catch (e) {
8284
- logger$9.error('WebRTC transport disconnect, error', e);
8333
+ logger$3.error('WebRTC transport disconnect, error', e);
8285
8334
  }
8286
8335
  }
8287
8336
  }
@@ -8318,25 +8367,25 @@ class WebRTCClient extends Emitter {
8318
8367
 
8319
8368
  stats.forEach(report => {
8320
8369
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8321
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8370
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8322
8371
  }
8323
8372
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8324
- audioBytesSent += report.bytesSent;
8373
+ audioBytesSent += Number(report.bytesSent);
8325
8374
  }
8326
8375
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8327
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8376
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8328
8377
  }
8329
8378
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8330
- packetsLost += report.packetsLost;
8331
- networkStats.packetsReceived = report.packetsReceived;
8332
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8379
+ packetsLost += Number(report.packetsLost);
8380
+ networkStats.packetsReceived = Number(report.packetsReceived);
8381
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8333
8382
  }
8334
8383
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8335
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8384
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8336
8385
  }
8337
8386
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8338
8387
  if ('framesPerSecond' in report) {
8339
- networkStats.framesPerSecond = report.framesPerSecond;
8388
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8340
8389
  }
8341
8390
  if ('framerateMean' in report) {
8342
8391
  // framerateMean is only available in FF
@@ -8344,34 +8393,38 @@ class WebRTCClient extends Emitter {
8344
8393
  }
8345
8394
  }
8346
8395
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8347
- packetsLost += report.packetsLost;
8348
- networkStats.roundTripTime = report.roundTripTime;
8349
- networkStats.jitter = report.jitter;
8396
+ packetsLost += Number(report.packetsLost);
8397
+ networkStats.roundTripTime = Number(report.roundTripTime);
8398
+ networkStats.jitter = Number(report.jitter);
8350
8399
  }
8351
8400
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8352
- packetsLost += report.packetsLost;
8401
+ packetsLost += Number(report.packetsLost);
8353
8402
  }
8354
8403
  if (report.type === 'transport') {
8355
- transportSent += report.bytesSent;
8356
- transportReceived += report.bytesReceived;
8404
+ transportSent += Number(report.bytesSent);
8405
+ transportReceived += Number(report.bytesReceived);
8357
8406
  }
8358
8407
  });
8359
8408
 
8360
8409
  networkStats.packetsLost = packetsLost;
8361
- networkStats.audioBytesSent = audioBytesSent;
8410
+ networkStats.totalAudioBytesSent = audioBytesSent;
8411
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8412
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8362
8413
  networkStats.audioBytesReceived = audioBytesReceived;
8363
- networkStats.videoBytesSent = videoBytesSent;
8364
- networkStats.videoBytesReceived = videoBytesReceived;
8414
+ networkStats.totalVideoBytesSent = videoBytesSent;
8415
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8416
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8417
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8418
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8365
8419
  networkStats.transportSent = transportSent;
8366
- networkStats.transportReceived = transportReceived;
8367
-
8368
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8369
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8370
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8420
+ networkStats.totalTransportReceived = transportReceived;
8421
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8371
8422
 
8372
- networkStats.bandwidth = bandwidth;
8423
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8424
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8425
+ + networkStats.transportSent;
8373
8426
 
8374
- this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8427
+ this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8375
8428
  this.sessionNetworkStats[sessionId].push(networkStats);
8376
8429
  }
8377
8430
 
@@ -8399,8 +8452,8 @@ const ON_CALL_FAILED = 'onCallFailed';
8399
8452
  const ON_CALL_ENDED = 'onCallEnded';
8400
8453
  const ON_CALL_ENDING = 'onCallEnding';
8401
8454
  const ON_MESSAGE = 'onMessage';
8402
- const ON_REINVITE = 'reinvite';
8403
- const ON_TRACK = 'onTrack';
8455
+ const ON_REINVITE$1 = 'reinvite';
8456
+ const ON_TRACK$1 = 'onTrack';
8404
8457
  const ON_AUDIO_STREAM = 'onAudioStream';
8405
8458
  const ON_VIDEO_STREAM = 'onVideoStream';
8406
8459
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8415,15 +8468,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8415
8468
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8416
8469
  const ON_CALL_ERROR = 'onCallError';
8417
8470
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8418
- const ON_NETWORK_STATS = 'onNetworkStats';
8471
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
8419
8472
  const ON_CHAT = 'phone/ON_CHAT';
8420
8473
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8421
- const ON_DISCONNECTED = 'onDisconnected';
8474
+ const ON_DISCONNECTED$1 = 'onDisconnected';
8422
8475
 
8423
8476
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8424
8477
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8425
8478
 
8426
- const events = [
8479
+ const events$1 = [
8427
8480
  ON_USER_AGENT,
8428
8481
  ON_REGISTERED,
8429
8482
  ON_UNREGISTERED,
@@ -8441,8 +8494,8 @@ const events = [
8441
8494
  ON_CALL_FAILED,
8442
8495
  ON_CALL_ENDED,
8443
8496
  ON_MESSAGE,
8444
- ON_REINVITE,
8445
- ON_TRACK,
8497
+ ON_REINVITE$1,
8498
+ ON_TRACK$1,
8446
8499
  ON_AUDIO_STREAM,
8447
8500
  ON_VIDEO_STREAM,
8448
8501
  ON_REMOVE_STREAM,
@@ -8457,11 +8510,11 @@ const events = [
8457
8510
  ON_CALL_ERROR,
8458
8511
  ON_CHAT,
8459
8512
  ON_SIGNAL,
8460
- ON_NETWORK_STATS,
8461
- ON_DISCONNECTED,
8513
+ ON_NETWORK_STATS$1,
8514
+ ON_DISCONNECTED$1,
8462
8515
  ];
8463
8516
 
8464
- const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
8517
+ const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
8465
8518
 
8466
8519
  class WebRTCPhone extends Emitter {
8467
8520
 
@@ -8534,7 +8587,7 @@ class WebRTCPhone extends Emitter {
8534
8587
  }).catch(error => {
8535
8588
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8536
8589
  console.error('register error', error, error.message, error.stack);
8537
- logger$8.error('WebRTC register error', { message: error.message, stack: error.stack });
8590
+ logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
8538
8591
  });
8539
8592
  }
8540
8593
 
@@ -8549,7 +8602,7 @@ class WebRTCPhone extends Emitter {
8549
8602
  if (!this.client) {
8550
8603
  return;
8551
8604
  }
8552
- logger$8.info('WebRTC phone stop');
8605
+ logger$4.info('WebRTC phone stop');
8553
8606
  this.client.stop();
8554
8607
  }
8555
8608
 
@@ -8564,7 +8617,7 @@ class WebRTCPhone extends Emitter {
8564
8617
  async sendReinvite(callSession , constraints = null, conference = false,
8565
8618
  audioOnly = false, iceRestart = false) {
8566
8619
  const sipSession = this.findSipSession(callSession);
8567
- logger$8.info('WebRTC phone - send reinvite', {
8620
+ logger$4.info('WebRTC phone - send reinvite', {
8568
8621
  sessionId: sipSession ? sipSession.id : null,
8569
8622
  constraints,
8570
8623
  audioOnly,
@@ -8601,7 +8654,7 @@ class WebRTCPhone extends Emitter {
8601
8654
  }
8602
8655
 
8603
8656
  startHeartbeat() {
8604
- logger$8.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8657
+ logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8605
8658
  if (!this.client || this.client.hasHeartbeat()) {
8606
8659
  return;
8607
8660
  }
@@ -8610,7 +8663,7 @@ class WebRTCPhone extends Emitter {
8610
8663
  }
8611
8664
 
8612
8665
  stopHeartbeat() {
8613
- logger$8.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8666
+ logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8614
8667
  if (!this.client) {
8615
8668
  return;
8616
8669
  }
@@ -8627,7 +8680,7 @@ class WebRTCPhone extends Emitter {
8627
8680
  }
8628
8681
 
8629
8682
  reconnect() {
8630
- logger$8.info('WebRTC phone - reconnect', { client: !!this.client });
8683
+ logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
8631
8684
  if (!this.client) {
8632
8685
  return;
8633
8686
  }
@@ -8668,10 +8721,15 @@ class WebRTCPhone extends Emitter {
8668
8721
  return false;
8669
8722
  }
8670
8723
 
8671
- logger$8.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8724
+ logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8672
8725
 
8673
8726
  this.client.downgradeToAudio(sipSession);
8674
8727
 
8728
+ if (callSession) {
8729
+ callSession.cameraEnabled = false;
8730
+ this._updateCallSession(callSession);
8731
+ }
8732
+
8675
8733
  if (withMessage) {
8676
8734
  this._sendReinviteMessage(callSession, false);
8677
8735
  }
@@ -8686,7 +8744,7 @@ class WebRTCPhone extends Emitter {
8686
8744
  return Promise.resolve(false);
8687
8745
  }
8688
8746
 
8689
- logger$8.info('Upgrade to video', {
8747
+ logger$4.info('Upgrade to video', {
8690
8748
  id: callSession ? callSession.getId() : null,
8691
8749
  constraints,
8692
8750
  isConference,
@@ -8699,6 +8757,11 @@ class WebRTCPhone extends Emitter {
8699
8757
 
8700
8758
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
8701
8759
 
8760
+ if (callSession) {
8761
+ callSession.cameraEnabled = true;
8762
+ this._updateCallSession(callSession);
8763
+ }
8764
+
8702
8765
  // If no stream is returned, it means we have to reinvite
8703
8766
  if (!newStream) {
8704
8767
  return true;
@@ -8721,7 +8784,7 @@ class WebRTCPhone extends Emitter {
8721
8784
 
8722
8785
  _sendReinviteMessage(callSession , isUpgrade ) {
8723
8786
  const sipSession = this.findSipSession(callSession);
8724
- logger$8.info('Sending reinvite message', {
8787
+ logger$4.info('Sending reinvite message', {
8725
8788
  id: callSession ? callSession.getId() : null,
8726
8789
  isUpgrade,
8727
8790
  });
@@ -8747,11 +8810,14 @@ class WebRTCPhone extends Emitter {
8747
8810
  // Monkey patch to know when canceled with the CANCEL message
8748
8811
  const onCancel = sipSession._onCancel.bind(sipSession);
8749
8812
  sipSession._onCancel = (message ) => {
8750
- logger$8.trace('on sip session canceled', { callId: message.callId });
8813
+ logger$4.trace('on sip session canceled', { callId: message.callId });
8751
8814
 
8752
8815
  onCancel(message);
8753
8816
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
8754
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
8817
+ const callSession = this._createCallSession(sipSession);
8818
+ delete this.callSessions[callSession.getId()];
8819
+
8820
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
8755
8821
  };
8756
8822
  } else if (sipSession instanceof invitation.Invitation) {
8757
8823
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -8772,17 +8838,19 @@ class WebRTCPhone extends Emitter {
8772
8838
  this.audioOutputVolume,
8773
8839
  );
8774
8840
  case sessionState.SessionState.Terminating:
8775
- logger$8.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8841
+ logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8776
8842
 
8777
8843
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
8778
8844
 
8779
8845
  break;
8780
8846
  case sessionState.SessionState.Terminated: {
8781
- logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8847
+ logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8782
8848
 
8849
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
8850
+ const callSession = this._createCallSession(sipSession);
8783
8851
  const wasCurrentSession = this._onCallTerminated(sipSession);
8784
8852
 
8785
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
8853
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
8786
8854
  }
8787
8855
  }
8788
8856
  });
@@ -8798,7 +8866,7 @@ class WebRTCPhone extends Emitter {
8798
8866
  const [stream] = event.streams;
8799
8867
  const kind = event && event.track && event.track.kind;
8800
8868
 
8801
- logger$8.info('on track stream called on the peer connection', {
8869
+ logger$4.info('on track stream called on the peer connection', {
8802
8870
  callId: this.getSipSessionId(sipSession),
8803
8871
  streamId: stream ? stream.id : null,
8804
8872
  tracks: stream ? stream.getTracks() : null,
@@ -8818,7 +8886,7 @@ class WebRTCPhone extends Emitter {
8818
8886
  };
8819
8887
 
8820
8888
  peerConnection.onremovestream = event => {
8821
- logger$8.info('on remove stream called on the peer connection', {
8889
+ logger$4.info('on remove stream called on the peer connection', {
8822
8890
  id: event.stream.id,
8823
8891
  tracks: event.stream.getTracks(),
8824
8892
  });
@@ -8828,7 +8896,7 @@ class WebRTCPhone extends Emitter {
8828
8896
  }
8829
8897
 
8830
8898
  async startScreenSharing(constraints , callSession ) {
8831
- logger$8.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8899
+ logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8832
8900
 
8833
8901
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
8834
8902
  if (!screenShareStream) {
@@ -8868,7 +8936,7 @@ class WebRTCPhone extends Emitter {
8868
8936
  return;
8869
8937
  }
8870
8938
 
8871
- logger$8.info('WebRTC phone - stop screen sharing', {
8939
+ logger$4.info('WebRTC phone - stop screen sharing', {
8872
8940
  restoreLocalStream,
8873
8941
  });
8874
8942
 
@@ -8924,24 +8992,26 @@ class WebRTCPhone extends Emitter {
8924
8992
  const pc = this.client.getPeerConnection(sipSessionId);
8925
8993
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
8926
8994
 
8927
- logger$8.info('WebRTC phone - on screensharing', {
8995
+ logger$4.info('WebRTC phone - on screensharing', {
8928
8996
  hadVideo,
8929
8997
  id: this.getSipSessionId(sipSession),
8930
8998
  screenTrack,
8931
8999
  });
8932
9000
 
8933
- screenTrack.onended = () => {
8934
- logger$8.info('WebRTC phone - on screenshare ended', {
8935
- hadVideo,
8936
- id: this.getSipSessionId(sipSession),
8937
- screenTrack,
8938
- });
9001
+ if (screenTrack) {
9002
+ screenTrack.onended = () => {
9003
+ logger$4.info('WebRTC phone - on screenshare ended', {
9004
+ hadVideo,
9005
+ id: this.getSipSessionId(sipSession),
9006
+ screenTrack,
9007
+ });
8939
9008
 
8940
- this.eventEmitter.emit(
8941
- ON_SHARE_SCREEN_ENDING,
8942
- this._createCallSession(sipSession, callSession),
8943
- );
8944
- };
9009
+ this.eventEmitter.emit(
9010
+ ON_SHARE_SCREEN_ENDING,
9011
+ this._createCallSession(sipSession, callSession),
9012
+ );
9013
+ };
9014
+ }
8945
9015
 
8946
9016
  this.currentScreenShare = {
8947
9017
  stream: screenStream,
@@ -8961,7 +9031,7 @@ class WebRTCPhone extends Emitter {
8961
9031
  }
8962
9032
 
8963
9033
  _onCallAccepted(sipSession , cameraEnabled ) {
8964
- logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9034
+ logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
8965
9035
 
8966
9036
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
8967
9037
  this.currentSipSession = sipSession;
@@ -8979,7 +9049,7 @@ class WebRTCPhone extends Emitter {
8979
9049
  }
8980
9050
 
8981
9051
  changeAudioDevice(id ) {
8982
- logger$8.info('WebRTC phone - change audio device', { deviceId: id });
9052
+ logger$4.info('WebRTC phone - change audio device', { deviceId: id });
8983
9053
  this.audioOutputDeviceId = id;
8984
9054
  this.client.changeAudioOutputDevice(id);
8985
9055
  }
@@ -8989,14 +9059,14 @@ class WebRTCPhone extends Emitter {
8989
9059
  }
8990
9060
 
8991
9061
  changeRingDevice(id ) {
8992
- logger$8.info('WebRTC phone - changing ring device', { id });
9062
+ logger$4.info('WebRTC phone - changing ring device', { id });
8993
9063
 
8994
9064
  this.audioRingDeviceId = id;
8995
9065
  }
8996
9066
 
8997
9067
  // volume is a value between 0 and 1
8998
9068
  changeAudioVolume(volume ) {
8999
- logger$8.info('WebRTC phone - changing audio volume', { volume });
9069
+ logger$4.info('WebRTC phone - changing audio volume', { volume });
9000
9070
 
9001
9071
  this.audioOutputVolume = volume;
9002
9072
  this.client.changeAudioOutputVolume(volume);
@@ -9004,31 +9074,31 @@ class WebRTCPhone extends Emitter {
9004
9074
 
9005
9075
  // volume is a value between 0 and 1
9006
9076
  changeRingVolume(volume ) {
9007
- logger$8.info('WebRTC phone - changing ring volume', { volume });
9077
+ logger$4.info('WebRTC phone - changing ring volume', { volume });
9008
9078
 
9009
9079
  this.audioRingVolume = volume;
9010
9080
  }
9011
9081
 
9012
9082
  changeAudioInputDevice(id ) {
9013
- logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9083
+ logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
9014
9084
 
9015
9085
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9016
9086
  }
9017
9087
 
9018
9088
  changeVideoInputDevice(id ) {
9019
- logger$8.info('WebRTC phone - change video input device', { deviceId: id });
9089
+ logger$4.info('WebRTC phone - change video input device', { deviceId: id });
9020
9090
 
9021
9091
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9022
9092
  }
9023
9093
 
9024
9094
  changeSessionVideoInputDevice(id ) {
9025
- logger$8.info('WebRTC phone - change session video input device', { deviceId: id });
9095
+ logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
9026
9096
 
9027
9097
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9028
9098
  }
9029
9099
 
9030
9100
  _onCallTerminated(sipSession ) {
9031
- logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9101
+ logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9032
9102
 
9033
9103
  const callSession = this._createCallSession(sipSession);
9034
9104
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -9062,7 +9132,7 @@ class WebRTCPhone extends Emitter {
9062
9132
  const hasIncomingCallSession = this.hasIncomingCallSession();
9063
9133
 
9064
9134
  // Re-trigger incoming call event for remaining incoming calls
9065
- logger$8.info('WebRTC phone - check to re-trigger incoming call', {
9135
+ logger$4.info('WebRTC phone - check to re-trigger incoming call', {
9066
9136
  sipId: sipSession.id,
9067
9137
  shouldRetrigger,
9068
9138
  hasIncomingCallSession,
@@ -9153,37 +9223,37 @@ class WebRTCPhone extends Emitter {
9153
9223
 
9154
9224
  // Deprecated
9155
9225
  getLocalStreamForCall(callSession ) {
9156
- logger$8.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9226
+ logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9157
9227
 
9158
9228
  return this.getLocalStream(callSession);
9159
9229
  }
9160
9230
 
9161
9231
  // Deprecated
9162
9232
  getRemoteStreamForCall(callSession ) {
9163
- logger$8.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9233
+ logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9164
9234
 
9165
9235
  return this.getRemoteVideoStream(callSession);
9166
9236
  }
9167
9237
 
9168
9238
  getRemoteStreamsForCall(callSession ) {
9169
- logger$8.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9239
+ logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9170
9240
 
9171
9241
  return this.getRemoteStream(callSession);
9172
9242
  }
9173
9243
 
9174
9244
  accept(callSession , cameraEnabled ) {
9175
- logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9245
+ logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9176
9246
  if (this.currentSipSession) {
9177
9247
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9178
9248
  }
9179
9249
 
9180
9250
  if (!callSession) {
9181
- logger$8.warn('no CallSession to accept.');
9251
+ logger$4.warn('no CallSession to accept.');
9182
9252
  return Promise.resolve(null);
9183
9253
  }
9184
9254
 
9185
9255
  if (callSession.getId() in this.acceptedSessions) {
9186
- logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9256
+ logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9187
9257
  return Promise.resolve(callSession.sipCallId);
9188
9258
  }
9189
9259
 
@@ -9195,24 +9265,24 @@ class WebRTCPhone extends Emitter {
9195
9265
  const sipSession = this.client.getSipSession(callSession.getId());
9196
9266
  if (sipSession) {
9197
9267
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9198
- logger$8.warn('Trying to answer a terminated sipSession.');
9268
+ logger$4.warn('Trying to answer a terminated sipSession.');
9199
9269
 
9200
9270
  return Promise.resolve(null);
9201
9271
  }
9202
9272
 
9203
- logger$8.info('accept call, session found', { sipId: sipSession.id });
9273
+ logger$4.info('accept call, session found', { sipId: sipSession.id });
9204
9274
 
9205
9275
  // $FlowFixMe
9206
9276
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9207
9277
  return callSession.sipCallId;
9208
9278
  }).catch(e => {
9209
- logger$8.error(e);
9279
+ logger$4.error(e);
9210
9280
  this.endCurrentCall(callSession);
9211
9281
  throw e;
9212
9282
  });
9213
9283
  }
9214
9284
 
9215
- logger$8.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9285
+ logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9216
9286
 
9217
9287
  return Promise.resolve(null);
9218
9288
  }
@@ -9222,7 +9292,7 @@ class WebRTCPhone extends Emitter {
9222
9292
  }
9223
9293
 
9224
9294
  async reject(callSession ) {
9225
- logger$8.info('reject WebRTC called', { id: callSession.getId() });
9295
+ logger$4.info('reject WebRTC called', { id: callSession.getId() });
9226
9296
 
9227
9297
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9228
9298
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9234,14 +9304,14 @@ class WebRTCPhone extends Emitter {
9234
9304
 
9235
9305
  const sipSession = this.findSipSession(callSession);
9236
9306
  if (sipSession) {
9237
- logger$8.info('WebRTC rejecting', { sipId: sipSession.id });
9307
+ logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
9238
9308
 
9239
9309
  this.client.hangup(sipSession);
9240
9310
  }
9241
9311
  }
9242
9312
 
9243
9313
  async ignore(callSession ) {
9244
- logger$8.info('WebRTC ignore', { id: callSession.getId() });
9314
+ logger$4.info('WebRTC ignore', { id: callSession.getId() });
9245
9315
 
9246
9316
  // kill the ring
9247
9317
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9253,14 +9323,14 @@ class WebRTCPhone extends Emitter {
9253
9323
  const sipSession = this.findSipSession(callSession);
9254
9324
 
9255
9325
  if (sipSession) {
9256
- logger$8.info('WebRTC atxfer', { sipId: sipSession.id });
9326
+ logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
9257
9327
 
9258
9328
  return this.client.atxfer(sipSession);
9259
9329
  }
9260
9330
  }
9261
9331
 
9262
9332
  hold(callSession , withEvent = true, isConference = false) {
9263
- logger$8.info('WebRTC hold', { id: callSession.getId() });
9333
+ logger$4.info('WebRTC hold', { id: callSession.getId() });
9264
9334
 
9265
9335
  const sipSession = this.findSipSession(callSession);
9266
9336
 
@@ -9275,18 +9345,18 @@ class WebRTCPhone extends Emitter {
9275
9345
  }
9276
9346
 
9277
9347
  resume(callSession , isConference = false, withEvent = true) {
9278
- logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9348
+ logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9279
9349
 
9280
9350
  const sipSession = this.findSipSession(callSession);
9281
9351
  if (!sipSession) {
9282
9352
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9283
9353
  }
9284
9354
 
9285
- logger$8.info('WebRTC resuming', { sipId: sipSession.id });
9355
+ logger$4.info('WebRTC resuming', { sipId: sipSession.id });
9286
9356
 
9287
9357
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9288
9358
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9289
- logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9359
+ logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9290
9360
  this.holdSipSession(this.currentSipSession, callSession);
9291
9361
  }
9292
9362
 
@@ -9311,7 +9381,7 @@ class WebRTCPhone extends Emitter {
9311
9381
  const sessionId = this.getSipSessionId(sipSession);
9312
9382
  const hasVideo = this.client.hasLocalVideo(sessionId);
9313
9383
 
9314
- logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9384
+ logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9315
9385
 
9316
9386
  // Stop screenshre if needed
9317
9387
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9342,7 +9412,7 @@ class WebRTCPhone extends Emitter {
9342
9412
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9343
9413
  }
9344
9414
  const sessionId = this.getSipSessionId(sipSession);
9345
- logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9415
+ logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
9346
9416
 
9347
9417
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9348
9418
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9386,14 +9456,14 @@ class WebRTCPhone extends Emitter {
9386
9456
  }
9387
9457
 
9388
9458
  mute(callSession , withEvent = true) {
9389
- logger$8.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9459
+ logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9390
9460
 
9391
9461
  const sipSession = this.findSipSession(callSession);
9392
9462
  if (!sipSession) {
9393
9463
  return;
9394
9464
  }
9395
9465
 
9396
- logger$8.info('WebRTC muting', { sipId: sipSession.id });
9466
+ logger$4.info('WebRTC muting', { sipId: sipSession.id });
9397
9467
  this.client.mute(sipSession);
9398
9468
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9399
9469
 
@@ -9407,14 +9477,14 @@ class WebRTCPhone extends Emitter {
9407
9477
  }
9408
9478
 
9409
9479
  unmute(callSession , withEvent = true) {
9410
- logger$8.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9480
+ logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9411
9481
 
9412
9482
  const sipSession = this.findSipSession(callSession);
9413
9483
  if (!sipSession) {
9414
9484
  return;
9415
9485
  }
9416
9486
 
9417
- logger$8.info('WebRTC unmuting', { sipId: sipSession.id });
9487
+ logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
9418
9488
  this.client.unmute(sipSession);
9419
9489
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9420
9490
 
@@ -9441,7 +9511,7 @@ class WebRTCPhone extends Emitter {
9441
9511
  if (!sipSession) {
9442
9512
  return;
9443
9513
  }
9444
- logger$8.info('WebRTC turn camera on', { sipId: sipSession.id });
9514
+ logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
9445
9515
 
9446
9516
  this.client.toggleCameraOn(sipSession);
9447
9517
 
@@ -9453,7 +9523,7 @@ class WebRTCPhone extends Emitter {
9453
9523
  if (!sipSession) {
9454
9524
  return;
9455
9525
  }
9456
- logger$8.info('WebRTC turn camera off', { sipId: sipSession.id });
9526
+ logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
9457
9527
 
9458
9528
  this.client.toggleCameraOff(sipSession);
9459
9529
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9465,7 +9535,7 @@ class WebRTCPhone extends Emitter {
9465
9535
  return;
9466
9536
  }
9467
9537
 
9468
- logger$8.info('WebRTC send key', { sipId: sipSession.id, tone });
9538
+ logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
9469
9539
  this.client.sendDTMF(sipSession, tone);
9470
9540
  }
9471
9541
 
@@ -9473,7 +9543,7 @@ class WebRTCPhone extends Emitter {
9473
9543
  // @TODO: line is not used here
9474
9544
  async makeCall(number , line , cameraEnabled ,
9475
9545
  audioOnly = false, conference = false) {
9476
- logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9546
+ logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9477
9547
  if (!number) {
9478
9548
  return Promise.resolve(null);
9479
9549
  }
@@ -9483,7 +9553,7 @@ class WebRTCPhone extends Emitter {
9483
9553
  }
9484
9554
  if (this.currentSipSession) {
9485
9555
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9486
- logger$8.warn('Unable to hold current session when making another call', e);
9556
+ logger$4.warn('Unable to hold current session when making another call', e);
9487
9557
  });
9488
9558
  }
9489
9559
 
@@ -9493,7 +9563,7 @@ class WebRTCPhone extends Emitter {
9493
9563
  this._bindEvents(sipSession);
9494
9564
  } catch (error) {
9495
9565
  console.warn(error);
9496
- logger$8.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9566
+ logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9497
9567
  return Promise.resolve(null);
9498
9568
  }
9499
9569
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -9521,7 +9591,7 @@ class WebRTCPhone extends Emitter {
9521
9591
  return;
9522
9592
  }
9523
9593
 
9524
- logger$8.info('WebRTC transfer', { sipId: sipSession.id, target });
9594
+ logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
9525
9595
 
9526
9596
  this.client.transfer(sipSession, target);
9527
9597
  }
@@ -9530,7 +9600,7 @@ class WebRTCPhone extends Emitter {
9530
9600
  const sipSession = this.client.getSipSession(source.sipCallId);
9531
9601
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9532
9602
 
9533
- logger$8.info('WebRTC indirect transfer', {
9603
+ logger$4.info('WebRTC indirect transfer', {
9534
9604
  sipId: sipSession ? sipSession.id : null,
9535
9605
  target: sipSessionTarget ? sipSessionTarget.id : null,
9536
9606
  });
@@ -9569,7 +9639,7 @@ class WebRTCPhone extends Emitter {
9569
9639
  return false;
9570
9640
  }
9571
9641
 
9572
- logger$8.info('WebRTC hangup', { sipId: sipSession.id });
9642
+ logger$4.info('WebRTC hangup', { sipId: sipSession.id });
9573
9643
 
9574
9644
  const sipSessionId = this.getSipSessionId(sipSession);
9575
9645
 
@@ -9615,7 +9685,7 @@ class WebRTCPhone extends Emitter {
9615
9685
  endCurrentCall(callSession ) {
9616
9686
  const isCurrent = this.isCurrentCallSipSession(callSession);
9617
9687
 
9618
- logger$8.info('Ending current call', {
9688
+ logger$4.info('Ending current call', {
9619
9689
  id: callSession ? callSession.getId() : null,
9620
9690
  isCurrent,
9621
9691
  });
@@ -9639,7 +9709,7 @@ class WebRTCPhone extends Emitter {
9639
9709
  }
9640
9710
 
9641
9711
  async close() {
9642
- logger$8.info('WebRTC close');
9712
+ logger$4.info('WebRTC close');
9643
9713
 
9644
9714
  try {
9645
9715
  await Promise.race([
@@ -9647,7 +9717,7 @@ class WebRTCPhone extends Emitter {
9647
9717
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9648
9718
  ]);
9649
9719
  } catch (e) {
9650
- logger$8.error('WebRTC close, unregister error', e);
9720
+ logger$4.error('WebRTC close, unregister error', e);
9651
9721
  }
9652
9722
 
9653
9723
  this.client.close();
@@ -9665,12 +9735,12 @@ class WebRTCPhone extends Emitter {
9665
9735
  }
9666
9736
 
9667
9737
  enableRinging() {
9668
- logger$8.info('WebRTC enable ringing');
9738
+ logger$4.info('WebRTC enable ringing');
9669
9739
  this.ringingEnabled = true;
9670
9740
  }
9671
9741
 
9672
9742
  disableRinging() {
9673
- logger$8.info('WebRTC disable ringing');
9743
+ logger$4.info('WebRTC disable ringing');
9674
9744
  this.ringingEnabled = false;
9675
9745
  }
9676
9746
 
@@ -9710,7 +9780,7 @@ class WebRTCPhone extends Emitter {
9710
9780
 
9711
9781
  // Deprecated
9712
9782
  getLocalMediaStream(callSession ) {
9713
- logger$8.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9783
+ logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9714
9784
  return this.getLocalStream(callSession);
9715
9785
  }
9716
9786
 
@@ -9730,6 +9800,10 @@ class WebRTCPhone extends Emitter {
9730
9800
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9731
9801
  }
9732
9802
 
9803
+ getRemoteVideoStreamFromPc(callSession ) {
9804
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
9805
+ }
9806
+
9733
9807
  hasRemoteVideo(callSession ) {
9734
9808
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9735
9809
  }
@@ -9748,7 +9822,7 @@ class WebRTCPhone extends Emitter {
9748
9822
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
9749
9823
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
9750
9824
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
9751
- logger$8.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9825
+ logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9752
9826
 
9753
9827
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
9754
9828
  this.incomingSessions.push(callSession.getId());
@@ -9771,7 +9845,7 @@ class WebRTCPhone extends Emitter {
9771
9845
  });
9772
9846
 
9773
9847
  this.client.on(this.client.ON_REINVITE, (...args) => {
9774
- logger$8.info('WebRTC on reinvite', {
9848
+ logger$4.info('WebRTC on reinvite', {
9775
9849
  sessionId: args[0].id,
9776
9850
  inviteId: args[1].id,
9777
9851
  updatedCalleeName: args[2],
@@ -9791,7 +9865,7 @@ class WebRTCPhone extends Emitter {
9791
9865
  });
9792
9866
 
9793
9867
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9794
- logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9868
+ logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
9795
9869
 
9796
9870
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
9797
9871
 
@@ -9802,22 +9876,22 @@ class WebRTCPhone extends Emitter {
9802
9876
  this.client.on('ended', () => {});
9803
9877
 
9804
9878
  this.client.on(this.client.ON_ERROR, e => {
9805
- logger$8.error('WebRTC error', e);
9879
+ logger$4.error('WebRTC error', e);
9806
9880
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9807
9881
  });
9808
9882
 
9809
9883
  this.client.on(this.client.UNREGISTERED, () => {
9810
- logger$8.info('WebRTC unregistered');
9884
+ logger$4.info('WebRTC unregistered');
9811
9885
  this.eventEmitter.emit(ON_UNREGISTERED);
9812
9886
  });
9813
9887
 
9814
9888
  this.client.on(this.client.ON_DISCONNECTED, () => {
9815
- logger$8.info('WebRTC disconnected');
9816
- this.eventEmitter.emit(ON_DISCONNECTED);
9889
+ logger$4.info('WebRTC disconnected');
9890
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
9817
9891
  });
9818
9892
 
9819
9893
  this.client.on(this.client.REGISTERED, () => {
9820
- logger$8.info('WebRTC registered', {
9894
+ logger$4.info('WebRTC registered', {
9821
9895
  shouldSendReinvite: this.shouldSendReinvite,
9822
9896
  state: this.currentSipSession ? this.currentSipSession.state : null,
9823
9897
  currentSipSession: !!this.currentSipSession,
@@ -9830,23 +9904,27 @@ class WebRTCPhone extends Emitter {
9830
9904
  if (this.shouldSendReinvite && this.currentSipSession
9831
9905
  && this.currentSipSession.state === sessionState.SessionState.Established) {
9832
9906
  this.shouldSendReinvite = false;
9907
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
9908
+ const isConference = pc ? pc.sfu : false;
9909
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
9910
+
9833
9911
  try {
9834
9912
  // Send reinvite with iceRestart
9835
- this.sendReinvite(this.currentCallSession, null, false, false, true);
9913
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
9836
9914
  } catch (e) {
9837
- logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9915
+ logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9838
9916
  }
9839
9917
  }
9840
9918
  });
9841
9919
 
9842
9920
  this.client.on(this.client.CONNECTED, () => {
9843
- logger$8.info('WebRTC client connected');
9921
+ logger$4.info('WebRTC client connected');
9844
9922
 
9845
9923
  this.stopHeartbeat();
9846
9924
  });
9847
9925
 
9848
9926
  this.client.on(this.client.DISCONNECTED, () => {
9849
- logger$8.info('WebRTC client disconnected');
9927
+ logger$4.info('WebRTC client disconnected');
9850
9928
 
9851
9929
  this.eventEmitter.emit(ON_UNREGISTERED);
9852
9930
 
@@ -9860,7 +9938,7 @@ class WebRTCPhone extends Emitter {
9860
9938
  });
9861
9939
 
9862
9940
  this.client.on(this.client.ON_TRACK, (session, event) => {
9863
- this.eventEmitter.emit(ON_TRACK, session, event);
9941
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
9864
9942
  });
9865
9943
 
9866
9944
  this.client.on('onVideoInputChange', stream => {
@@ -9875,7 +9953,7 @@ class WebRTCPhone extends Emitter {
9875
9953
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
9876
9954
  const callSession = this.getCallSession(this.getSipSessionId(session));
9877
9955
 
9878
- this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
9956
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
9879
9957
  });
9880
9958
 
9881
9959
  // Used when upgrading directly in screenshare mode
@@ -9884,7 +9962,7 @@ class WebRTCPhone extends Emitter {
9884
9962
  const localStream = this.client.getLocalStream(sipSessionId);
9885
9963
  const callSession = this.callSessions[sipSessionId];
9886
9964
 
9887
- logger$8.info('Updrading directly in screensharing mode', {
9965
+ logger$4.info('Updrading directly in screensharing mode', {
9888
9966
  sipSessionId,
9889
9967
  tracks: localStream ? localStream.getTracks() : null,
9890
9968
  });
@@ -9916,6 +9994,15 @@ class WebRTCPhone extends Emitter {
9916
9994
  return this.client.getSipSessionId(sipSession);
9917
9995
  }
9918
9996
 
9997
+ _updateCallSession(callSession ) {
9998
+ const sipSession = this.findSipSession(callSession);
9999
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10000
+
10001
+ if (sipSessionId) {
10002
+ this.callSessions[sipSessionId] = callSession;
10003
+ }
10004
+ }
10005
+
9919
10006
  _onMessage(message ) {
9920
10007
  if (!message || message.method !== 'MESSAGE') {
9921
10008
  return;
@@ -10053,8 +10140,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10053
10140
  ON_CALL_ENDED: ON_CALL_ENDED,
10054
10141
  ON_CALL_ENDING: ON_CALL_ENDING,
10055
10142
  ON_MESSAGE: ON_MESSAGE,
10056
- ON_REINVITE: ON_REINVITE,
10057
- ON_TRACK: ON_TRACK,
10143
+ ON_REINVITE: ON_REINVITE$1,
10144
+ ON_TRACK: ON_TRACK$1,
10058
10145
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10059
10146
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10060
10147
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10069,19 +10156,19 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10069
10156
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10070
10157
  ON_CALL_ERROR: ON_CALL_ERROR,
10071
10158
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10072
- ON_NETWORK_STATS: ON_NETWORK_STATS,
10159
+ ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10073
10160
  ON_CHAT: ON_CHAT,
10074
10161
  ON_SIGNAL: ON_SIGNAL,
10075
- ON_DISCONNECTED: ON_DISCONNECTED,
10162
+ ON_DISCONNECTED: ON_DISCONNECTED$1,
10076
10163
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10077
10164
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10078
- events: events,
10165
+ events: events$1,
10079
10166
  'default': WebRTCPhone
10080
10167
  });
10081
10168
 
10082
10169
  //
10083
10170
 
10084
- const logger$7 = IssueReporter$1.loggerFor('simple-phone');
10171
+ const logger$5 = IssueReporter$1.loggerFor('simple-phone');
10085
10172
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
10086
10173
  const protocolLogger = IssueReporter$1.loggerFor('sip');
10087
10174
 
@@ -10188,7 +10275,7 @@ class Phone extends Emitter {
10188
10275
  async disconnect() {
10189
10276
  if (this.phone) {
10190
10277
  if (this.phone.hasAnActiveCall()) {
10191
- logger$7.info('hangup call on disconnect');
10278
+ logger$5.info('hangup call on disconnect');
10192
10279
  // $FlowFixMe
10193
10280
  await this.phone.hangup();
10194
10281
  }
@@ -10211,13 +10298,13 @@ class Phone extends Emitter {
10211
10298
  }
10212
10299
 
10213
10300
  async hangup(callSession ) {
10214
- logger$7.info('hangup via simple phone', { callId: callSession.getId() });
10301
+ logger$5.info('hangup via simple phone', { callId: callSession.getId() });
10215
10302
 
10216
10303
  return this.phone && this.phone.hangup(callSession);
10217
10304
  }
10218
10305
 
10219
10306
  async accept(callSession , cameraEnabled ) {
10220
- logger$7.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10307
+ logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10221
10308
 
10222
10309
  return this.phone && this.phone.accept(callSession, cameraEnabled);
10223
10310
  }
@@ -10256,7 +10343,7 @@ class Phone extends Emitter {
10256
10343
  muteViaAPI(callSession ) {
10257
10344
  if (callSession && callSession.callId) {
10258
10345
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
10259
- logger$7.error('Mute via API, error', e);
10346
+ logger$5.error('Mute via API, error', e);
10260
10347
  });
10261
10348
  }
10262
10349
  }
@@ -10264,7 +10351,7 @@ class Phone extends Emitter {
10264
10351
  unmuteViaAPI(callSession ) {
10265
10352
  if (callSession && callSession.callId) {
10266
10353
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
10267
- logger$7.error('Unmute via API, error', e);
10354
+ logger$5.error('Unmute via API, error', e);
10268
10355
  });
10269
10356
  }
10270
10357
  }
@@ -10372,7 +10459,7 @@ class Phone extends Emitter {
10372
10459
 
10373
10460
  // @Deprecated
10374
10461
  getLocalMediaStream(callSession ) {
10375
- logger$7.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10462
+ logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10376
10463
 
10377
10464
  return this.phone && this.phone.getLocalStream(callSession);
10378
10465
  }
@@ -10395,24 +10482,29 @@ class Phone extends Emitter {
10395
10482
 
10396
10483
  // @Deprecated
10397
10484
  getRemoteStreamForCall(callSession ) {
10398
- logger$7.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10485
+ logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10399
10486
  return this.getRemoteStream(callSession);
10400
10487
  }
10401
10488
 
10402
10489
  // Returns remote streams directly from the peerConnection
10403
10490
  // @Deprecated
10404
10491
  getRemoteStreamsForCall(callSession ) {
10405
- logger$7.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10492
+ logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10406
10493
  return this.getLocalStream(callSession);
10407
10494
  }
10408
10495
 
10409
10496
  // @Deprecated
10410
10497
  getRemoteVideoStreamForCall(callSession ) {
10411
- logger$7.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10498
+ logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10412
10499
 
10413
10500
  return this.getRemoteVideoStream(callSession);
10414
10501
  }
10415
10502
 
10503
+ // Useful in a react-native environment when remoteMediaStream is not updated
10504
+ getRemoteVideoStreamFromPc(callSession ) {
10505
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10506
+ }
10507
+
10416
10508
  hasVideo(callSession ) {
10417
10509
  return this.phone ? this.phone.hasVideo(callSession) : false;
10418
10510
  }
@@ -10464,7 +10556,7 @@ class Phone extends Emitter {
10464
10556
 
10465
10557
  _transferEvents() {
10466
10558
  this.unbind();
10467
- [...events$1, ...transportEvents].forEach(event => {
10559
+ [...events, ...transportEvents].forEach(event => {
10468
10560
  this.client.on(event, (...args) =>
10469
10561
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10470
10562
  });
@@ -10486,7 +10578,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10486
10578
 
10487
10579
  //
10488
10580
 
10489
- const SOCKET_EVENTS$1 = {
10581
+ const SOCKET_EVENTS = {
10490
10582
  ON_OPEN: 'onopen',
10491
10583
  ON_MESSAGE: 'onmessage',
10492
10584
  ON_ERROR: 'onerror',
@@ -10572,6 +10664,7 @@ const AGENT_PAUSED = 'agent_paused';
10572
10664
  const AGENT_UNPAUSED = 'agent_unpaused';
10573
10665
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10574
10666
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10667
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10575
10668
 
10576
10669
  const BLACKLIST_EVENTS = [
10577
10670
  CHAT_MESSAGE_SENT,
@@ -10638,16 +10731,16 @@ class WebSocketClient extends Emitter {
10638
10731
 
10639
10732
  this.socket.onopen = () => {
10640
10733
  logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
10641
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10734
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10642
10735
  };
10643
10736
 
10644
10737
  this.socket.onerror = event => {
10645
10738
  logger$6.error('on Wazo WS error', event.target);
10646
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10739
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10647
10740
  };
10648
10741
 
10649
10742
  this.socket.onmessage = (event ) => {
10650
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
10743
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10651
10744
 
10652
10745
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10653
10746
  let { name } = message;
@@ -10680,11 +10773,11 @@ class WebSocketClient extends Emitter {
10680
10773
  token: this.token,
10681
10774
  });
10682
10775
  this.initialized = false;
10683
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
10776
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10684
10777
 
10685
10778
  switch (event.code) {
10686
10779
  case 4002:
10687
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
10780
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10688
10781
  break;
10689
10782
  }
10690
10783
  };
@@ -10800,7 +10893,7 @@ class WebSocketClient extends Emitter {
10800
10893
  break;
10801
10894
  case 'start':
10802
10895
  this.initialized = true;
10803
- this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
10896
+ this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
10804
10897
  break;
10805
10898
  default:
10806
10899
  this.eventEmitter.emit('message', message);
@@ -10847,7 +10940,7 @@ class WebSocketClient extends Emitter {
10847
10940
  logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
10848
10941
 
10849
10942
  this.close();
10850
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
10943
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
10851
10944
 
10852
10945
  if (this.onHeartBeatTimeout) {
10853
10946
  this.onHeartBeatTimeout();
@@ -10922,11 +11015,12 @@ WebSocketClient.eventLists = [
10922
11015
  AGENT_UNPAUSED,
10923
11016
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10924
11017
  CONFERENCE_ADHOC_DELETED,
11018
+ MEETING_USER_PROGRESS,
10925
11019
  ];
10926
11020
 
10927
11021
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10928
11022
  __proto__: null,
10929
- SOCKET_EVENTS: SOCKET_EVENTS$1,
11023
+ SOCKET_EVENTS: SOCKET_EVENTS,
10930
11024
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
10931
11025
  FAVORITE_ADDED: FAVORITE_ADDED,
10932
11026
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -10992,16 +11086,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10992
11086
  AGENT_UNPAUSED: AGENT_UNPAUSED,
10993
11087
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
10994
11088
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11089
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
10995
11090
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
10996
11091
  'default': WebSocketClient
10997
11092
  });
10998
11093
 
10999
11094
  //
11000
11095
 
11001
- const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11002
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11096
+ const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11097
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11003
11098
 
11004
- const logger$5 = IssueReporter$1.loggerFor('simple-ws-client');
11099
+ const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
11005
11100
 
11006
11101
  class Websocket extends Emitter {
11007
11102
 
@@ -11015,9 +11110,9 @@ class Websocket extends Emitter {
11015
11110
  // $FlowFixMe
11016
11111
  this[key] = OTHER_EVENTS[key];
11017
11112
  });
11018
- Object.keys(SOCKET_EVENTS).forEach(key => {
11113
+ Object.keys(SOCKET_EVENTS$1).forEach(key => {
11019
11114
  // $FlowFixMe
11020
- this[key] = SOCKET_EVENTS[key];
11115
+ this[key] = SOCKET_EVENTS$1[key];
11021
11116
  });
11022
11117
  this.eventLists = WebSocketClient.eventLists;
11023
11118
 
@@ -11025,7 +11120,7 @@ class Websocket extends Emitter {
11025
11120
  }
11026
11121
 
11027
11122
  open(host , session ) {
11028
- logger$5.info('open simple WebSocket', { host, token: session.token });
11123
+ logger$7.info('open simple WebSocket', { host, token: session.token });
11029
11124
  this.ws = new WebSocketClient(
11030
11125
  {
11031
11126
  host,
@@ -11053,7 +11148,7 @@ class Websocket extends Emitter {
11053
11148
  }
11054
11149
 
11055
11150
  updateToken(token ) {
11056
- logger$5.info('update token via simple Websocket', { token, ws: !!this.ws });
11151
+ logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
11057
11152
 
11058
11153
  if (!this.ws) {
11059
11154
  return;
@@ -11081,7 +11176,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11081
11176
 
11082
11177
  //
11083
11178
 
11084
- const logger$4 = IssueReporter$1.loggerFor('room');
11179
+ const logger$8 = IssueReporter$1.loggerFor('room');
11085
11180
 
11086
11181
  class Participant extends Emitter {
11087
11182
 
@@ -11203,7 +11298,7 @@ class Participant extends Emitter {
11203
11298
  }
11204
11299
 
11205
11300
  onTalking(isTalking ) {
11206
- logger$4.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11301
+ logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11207
11302
  this.isTalking = isTalking;
11208
11303
  // you may notice we're not broadcasting: since all participants are getting this info
11209
11304
  // directly from asterisk, there's no need to do so
@@ -11306,7 +11401,7 @@ class Participant extends Emitter {
11306
11401
  }
11307
11402
 
11308
11403
  updateStatus(status , broadcast = true) {
11309
- logger$4.info('updating participant status', { name: this.name, status });
11404
+ logger$8.info('updating participant status', { name: this.name, status });
11310
11405
 
11311
11406
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11312
11407
  if (status.audioMuted) {
@@ -11354,7 +11449,7 @@ class Participant extends Emitter {
11354
11449
 
11355
11450
  broadcastStatus(inboundStatus = null) {
11356
11451
  const status = inboundStatus || this.getStatus();
11357
- logger$4.info('broadcasting participant status', { callId: this.callId, status });
11452
+ logger$8.info('broadcasting participant status', { callId: this.callId, status });
11358
11453
 
11359
11454
  this.room.sendSignal({
11360
11455
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11390,9 +11485,9 @@ class LocalParticipant extends Participant {
11390
11485
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11391
11486
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11392
11487
 
11393
- const logger$3 = IssueReporter$1.loggerFor('sdk-room');
11488
+ const logger$9 = IssueReporter$1.loggerFor('sdk-room');
11394
11489
 
11395
- class Room$1 extends Emitter {
11490
+ class Room extends Emitter {
11396
11491
 
11397
11492
 
11398
11493
 
@@ -11450,7 +11545,7 @@ class Room$1 extends Emitter {
11450
11545
  extra = {},
11451
11546
  ) {
11452
11547
  super();
11453
- logger$3.info('room initialized', { callId, extension, sourceId, meetingUuid });
11548
+ logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
11454
11549
 
11455
11550
  // Represents the room callSession
11456
11551
  this.callSession = callSession;
@@ -11516,7 +11611,7 @@ class Room$1 extends Emitter {
11516
11611
  * @returns {Promise<Room>}
11517
11612
  */
11518
11613
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11519
- logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11614
+ logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
11520
11615
 
11521
11616
  if (!room) {
11522
11617
  await Wazo.Phone.connect();
@@ -11529,7 +11624,7 @@ class Room$1 extends Emitter {
11529
11624
 
11530
11625
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11531
11626
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11532
- logger$3.info('room call received via WS', { callId: data.call_id });
11627
+ logger$9.info('room call received via WS', { callId: data.call_id });
11533
11628
  if (room) {
11534
11629
  room.setCallId(data.call_id);
11535
11630
  }
@@ -11537,7 +11632,7 @@ class Room$1 extends Emitter {
11537
11632
 
11538
11633
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11539
11634
  // eslint-disable-next-line no-param-reassign
11540
- room = new Room$1(callSession, extension, null, null, extra);
11635
+ room = new Room(callSession, extension, null, null, extra);
11541
11636
 
11542
11637
  // Wait for the call to be accepted
11543
11638
  await new Promise((resolve, reject) => {
@@ -11558,7 +11653,7 @@ class Room$1 extends Emitter {
11558
11653
  // Retrieve conference
11559
11654
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11560
11655
 
11561
- logger$3.info('connected to room', {
11656
+ logger$9.info('connected to room', {
11562
11657
  sourceId: conference ? conference.sourceId : null,
11563
11658
  name: conference ? conference.name : null,
11564
11659
  });
@@ -11568,7 +11663,7 @@ class Room$1 extends Emitter {
11568
11663
  room.setName(conference.name);
11569
11664
  }
11570
11665
  } else if (meeting) {
11571
- logger$3.info('Already connected to meeting', {
11666
+ logger$9.info('Already connected to meeting', {
11572
11667
  uuid: meeting.uuid,
11573
11668
  name: meeting.name,
11574
11669
  });
@@ -11581,13 +11676,13 @@ class Room$1 extends Emitter {
11581
11676
  }
11582
11677
 
11583
11678
  static disconnect() {
11584
- logger$3.info('static disconnection to room');
11679
+ logger$9.info('static disconnection to room');
11585
11680
 
11586
11681
  Wazo.Phone.disconnect();
11587
11682
  }
11588
11683
 
11589
11684
  async disconnect() {
11590
- logger$3.info('disconnection to room called');
11685
+ logger$9.info('disconnection to room called');
11591
11686
 
11592
11687
  await Wazo.Phone.hangup(this.callSession);
11593
11688
  this.callSession = null;
@@ -11607,19 +11702,19 @@ class Room$1 extends Emitter {
11607
11702
  }
11608
11703
 
11609
11704
  setSourceId(sourceId ) {
11610
- logger$3.info('set room source id', { sourceId });
11705
+ logger$9.info('set room source id', { sourceId });
11611
11706
 
11612
11707
  this.sourceId = sourceId;
11613
11708
  }
11614
11709
 
11615
11710
  setMeetingUuid(meetingUuid ) {
11616
- logger$3.info('set meeting uuid', { meetingUuid });
11711
+ logger$9.info('set meeting uuid', { meetingUuid });
11617
11712
 
11618
11713
  this.meetingUuid = meetingUuid;
11619
11714
  }
11620
11715
 
11621
11716
  setCallId(callId ) {
11622
- logger$3.info('set room call id', { callId });
11717
+ logger$9.info('set room call id', { callId });
11623
11718
 
11624
11719
  if (callId) {
11625
11720
  this.callId = callId;
@@ -11627,7 +11722,7 @@ class Room$1 extends Emitter {
11627
11722
  }
11628
11723
 
11629
11724
  setName(name ) {
11630
- logger$3.info('set room name', { name });
11725
+ logger$9.info('set room name', { name });
11631
11726
 
11632
11727
  this.name = name;
11633
11728
  }
@@ -11646,7 +11741,7 @@ class Room$1 extends Emitter {
11646
11741
  }
11647
11742
 
11648
11743
  async startScreenSharing(constraints ) {
11649
- logger$3.info('start room screen sharing', { constraints });
11744
+ logger$9.info('start room screen sharing', { constraints });
11650
11745
 
11651
11746
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11652
11747
  if (!screensharingStream) {
@@ -11660,7 +11755,7 @@ class Room$1 extends Emitter {
11660
11755
  }
11661
11756
 
11662
11757
  async stopScreenSharing(restoreLocalStream = true) {
11663
- logger$3.info('stop room screen sharing');
11758
+ logger$9.info('stop room screen sharing');
11664
11759
 
11665
11760
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11666
11761
 
@@ -11672,7 +11767,7 @@ class Room$1 extends Emitter {
11672
11767
  }
11673
11768
 
11674
11769
  turnCameraOff() {
11675
- logger$3.info('turn room camera off');
11770
+ logger$9.info('turn room camera off');
11676
11771
 
11677
11772
  Wazo.Phone.turnCameraOff(this.callSession);
11678
11773
 
@@ -11682,7 +11777,7 @@ class Room$1 extends Emitter {
11682
11777
  }
11683
11778
 
11684
11779
  turnCameraOn() {
11685
- logger$3.info('turn room camera on');
11780
+ logger$9.info('turn room camera on');
11686
11781
 
11687
11782
  Wazo.Phone.turnCameraOn(this.callSession);
11688
11783
 
@@ -11692,7 +11787,7 @@ class Room$1 extends Emitter {
11692
11787
  }
11693
11788
 
11694
11789
  mute() {
11695
- logger$3.info('mute room');
11790
+ logger$9.info('mute room');
11696
11791
 
11697
11792
  Wazo.Phone.mute(this.callSession);
11698
11793
 
@@ -11700,7 +11795,7 @@ class Room$1 extends Emitter {
11700
11795
  }
11701
11796
 
11702
11797
  unmute() {
11703
- logger$3.info('unmute room');
11798
+ logger$9.info('unmute room');
11704
11799
 
11705
11800
  Wazo.Phone.unmute(this.callSession);
11706
11801
 
@@ -11720,7 +11815,7 @@ class Room$1 extends Emitter {
11720
11815
  }
11721
11816
 
11722
11817
  hold() {
11723
- logger$3.info('hold room');
11818
+ logger$9.info('hold room');
11724
11819
 
11725
11820
  Wazo.Phone.hold(this.callSession, true);
11726
11821
 
@@ -11730,7 +11825,7 @@ class Room$1 extends Emitter {
11730
11825
  }
11731
11826
 
11732
11827
  async resume() {
11733
- logger$3.info('resume room');
11828
+ logger$9.info('resume room');
11734
11829
 
11735
11830
  const newStream = await Wazo.Phone.resume(this.callSession, true);
11736
11831
 
@@ -11758,13 +11853,13 @@ class Room$1 extends Emitter {
11758
11853
  }
11759
11854
 
11760
11855
  sendDTMF(tone ) {
11761
- logger$3.info('send room DTMF', { tone });
11856
+ logger$9.info('send room DTMF', { tone });
11762
11857
 
11763
11858
  Wazo.Phone.sendDTMF(tone, this.callSession);
11764
11859
  }
11765
11860
 
11766
11861
  async sendReinvite(newConstraints = null) {
11767
- logger$3.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11862
+ logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11768
11863
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
11769
11864
 
11770
11865
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -11823,7 +11918,7 @@ class Room$1 extends Emitter {
11823
11918
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11824
11919
 
11825
11920
  this.on(this.ON_AUDIO_STREAM, stream => {
11826
- logger$3.info('on room audio stream');
11921
+ logger$9.info('on room audio stream');
11827
11922
 
11828
11923
  this.audioStream = stream;
11829
11924
  if (!this.roomAudioElement) {
@@ -11836,7 +11931,7 @@ class Room$1 extends Emitter {
11836
11931
  });
11837
11932
 
11838
11933
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
11839
- logger$3.info('on room video stream', { streamId });
11934
+ logger$9.info('on room video stream', { streamId });
11840
11935
 
11841
11936
  this._mapMsid(sipSession.body.body);
11842
11937
 
@@ -11851,7 +11946,7 @@ class Room$1 extends Emitter {
11851
11946
  });
11852
11947
 
11853
11948
  this.on(this.ON_REMOVE_STREAM, stream => {
11854
- logger$3.info('on room remove stream');
11949
+ logger$9.info('on room remove stream');
11855
11950
 
11856
11951
  const participant = this.participants.find(someParticipant =>
11857
11952
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -11983,7 +12078,7 @@ class Room$1 extends Emitter {
11983
12078
  const requester = this._getParticipantFromCallId(origin.callId);
11984
12079
  if (requester) {
11985
12080
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
11986
- logger$3.info('trigger room requester status', { origin });
12081
+ logger$9.info('trigger room requester status', { origin });
11987
12082
  requester.triggerUpdate('REQUESTER_UPDATE');
11988
12083
  }
11989
12084
  break;
@@ -12014,24 +12109,24 @@ class Room$1 extends Emitter {
12014
12109
 
12015
12110
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
12016
12111
  if (participant.user_uuid === session.uuid) {
12017
- logger$3.info('room current user joined');
12112
+ logger$9.info('room current user joined');
12018
12113
 
12019
12114
  // Retrieve participants via an API calls
12020
12115
  const conferenceId = this.sourceId || payload.data.conference_id;
12021
12116
  let response;
12022
12117
  try {
12023
12118
  if (this.meetingUuid) {
12024
- logger$3.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12119
+ logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12025
12120
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
12026
12121
  } else {
12027
- logger$3.info('fetching conference participants', { conferenceId });
12122
+ logger$9.info('fetching conference participants', { conferenceId });
12028
12123
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
12029
12124
  }
12030
12125
  } catch (e) {
12031
- logger$3.error('room participants fetching, error', e);
12126
+ logger$9.error('room participants fetching, error', e);
12032
12127
  }
12033
12128
  if (response) {
12034
- logger$3.info('conference participants fetched', { nb: response.items.length });
12129
+ logger$9.info('conference participants fetched', { nb: response.items.length });
12035
12130
  participants = response.items.map(item => {
12036
12131
  const isMe = item.call_id === this.callId;
12037
12132
 
@@ -12058,7 +12153,7 @@ class Room$1 extends Emitter {
12058
12153
  ? new Wazo.RemoteParticipant(this, participant)
12059
12154
  : null;
12060
12155
 
12061
- logger$3.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12156
+ logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12062
12157
 
12063
12158
  if (remoteParticipant) {
12064
12159
  this.participants.push(remoteParticipant);
@@ -12223,12 +12318,12 @@ class Room$1 extends Emitter {
12223
12318
 
12224
12319
  //
12225
12320
 
12226
- const logger$2 = IssueReporter$1.loggerFor('sdk-sip-room');
12321
+ const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
12227
12322
 
12228
- class SipRoom extends Room$1 {
12323
+ class SipRoom extends Room {
12229
12324
 
12230
12325
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12231
- logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12326
+ logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
12232
12327
 
12233
12328
  if (!room) {
12234
12329
  await Wazo.Phone.connect();
@@ -12244,7 +12339,7 @@ class SipRoom extends Room$1 {
12244
12339
  room.setCallId(room.callSession.call.id);
12245
12340
  }
12246
12341
 
12247
- logger$2.info('connected to room', {
12342
+ logger$a.info('connected to room', {
12248
12343
  extension: room.extension,
12249
12344
  });
12250
12345
 
@@ -12252,7 +12347,7 @@ class SipRoom extends Room$1 {
12252
12347
  }
12253
12348
 
12254
12349
  mute() {
12255
- logger$2.info('mute sip room');
12350
+ logger$a.info('mute sip room');
12256
12351
 
12257
12352
  Wazo.Phone.mute(this.callSession, false);
12258
12353
 
@@ -12260,7 +12355,7 @@ class SipRoom extends Room$1 {
12260
12355
  }
12261
12356
 
12262
12357
  unmute() {
12263
- logger$2.info('unmute sip room');
12358
+ logger$a.info('unmute sip room');
12264
12359
 
12265
12360
  Wazo.Phone.unmute(this.callSession, false);
12266
12361
 
@@ -12544,7 +12639,7 @@ class NotificationOptions {
12544
12639
 
12545
12640
 
12546
12641
  // Represents a conference room, like `9000`.
12547
- class Room {
12642
+ class Room$1 {
12548
12643
 
12549
12644
 
12550
12645
 
@@ -12565,7 +12660,7 @@ class Room {
12565
12660
  }
12566
12661
 
12567
12662
  connect(callSession ) {
12568
- return new Room({ ...this, connectedCallSession: callSession });
12663
+ return new Room$1({ ...this, connectedCallSession: callSession });
12569
12664
  }
12570
12665
 
12571
12666
  has(callSession ) {
@@ -12574,7 +12669,7 @@ class Room {
12574
12669
 
12575
12670
  addParticipant(uuid , extension , talking = null) {
12576
12671
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12577
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12672
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12578
12673
  }
12579
12674
 
12580
12675
  return this;
@@ -12593,7 +12688,7 @@ class Room {
12593
12688
  updatedParticipants.push(participant);
12594
12689
  }
12595
12690
 
12596
- return new Room({ ...this, participants: updatedParticipants });
12691
+ return new Room$1({ ...this, participants: updatedParticipants });
12597
12692
  }
12598
12693
 
12599
12694
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12609,7 +12704,7 @@ class Room {
12609
12704
  updatedParticipants.push(participant);
12610
12705
  }
12611
12706
 
12612
- return new Room({ ...this, participants: updatedParticipants });
12707
+ return new Room$1({ ...this, participants: updatedParticipants });
12613
12708
  }
12614
12709
 
12615
12710
  hasCallWithId(id ) {
@@ -12617,18 +12712,18 @@ class Room {
12617
12712
  }
12618
12713
 
12619
12714
  disconnect() {
12620
- return new Room({ ...this, connectedCallSession: null });
12715
+ return new Room$1({ ...this, connectedCallSession: null });
12621
12716
  }
12622
12717
 
12623
12718
  removeParticipantWithUUID(uuid ) {
12624
- return new Room({
12719
+ return new Room$1({
12625
12720
  ...this,
12626
12721
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12627
12722
  });
12628
12723
  }
12629
12724
 
12630
12725
  removeParticipantWithExtension(extension ) {
12631
- return new Room({
12726
+ return new Room$1({
12632
12727
  ...this,
12633
12728
  participants: this.participants.filter(participant => participant.extension !== extension),
12634
12729
  });
@@ -12639,7 +12734,7 @@ class Room {
12639
12734
  }
12640
12735
 
12641
12736
  static newFrom(room ) {
12642
- return newFrom(room, Room);
12737
+ return newFrom(room, Room$1);
12643
12738
  }
12644
12739
  }
12645
12740
 
@@ -12946,11 +13041,11 @@ var wazoWebsocket = {
12946
13041
  resolve();
12947
13042
  };
12948
13043
 
12949
- client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
13044
+ client.on(SOCKET_EVENTS.ON_ERROR, error => {
12950
13045
  handleError(`Connection error : ${error}`);
12951
13046
  });
12952
13047
 
12953
- client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
13048
+ client.on(SOCKET_EVENTS.ON_OPEN, () => {
12954
13049
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12955
13050
  client.setOnHeartbeatTimeout(() => {
12956
13051
  handleError('No response to heartbeat');
@@ -13051,7 +13146,7 @@ var webrtc = {
13051
13146
  }),
13052
13147
  };
13053
13148
 
13054
- const parseCandidate = line => {
13149
+ const parseCandidate$1 = line => {
13055
13150
  let parts;
13056
13151
  // Parse both variants.
13057
13152
  if (line.indexOf('a=candidate:') === 0) {
@@ -13142,7 +13237,7 @@ var SymmetricNat = {
13142
13237
  }
13143
13238
 
13144
13239
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13145
- const cand = parseCandidate(e.candidate.candidate);
13240
+ const cand = parseCandidate$1(e.candidate.candidate);
13146
13241
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13147
13242
  candidates[cand.relatedPort].push(cand.port);
13148
13243
  } else if (!e.candidate) {
@@ -13210,7 +13305,7 @@ var iceIpv4 = {
13210
13305
  const rawCandidate = e.candidate.candidate;
13211
13306
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13212
13307
  hasSrflxOrRelay = true;
13213
- const candidate = parseCandidate(e.candidate.candidate);
13308
+ const candidate = parseCandidate$1(e.candidate.candidate);
13214
13309
  ips.push(candidate.ip);
13215
13310
  }
13216
13311
  } else if (!e.candidate) {
@@ -13247,7 +13342,7 @@ var checks = [
13247
13342
 
13248
13343
  //
13249
13344
 
13250
- const logger$1 = IssueReporter$1.loggerFor('engine-check');
13345
+ const logger$b = IssueReporter$1.loggerFor('engine-check');
13251
13346
 
13252
13347
  class Checker {
13253
13348
 
@@ -13265,28 +13360,28 @@ class Checker {
13265
13360
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13266
13361
  await this._addEngineVersion();
13267
13362
 
13268
- logger$1.info('Engine check starting');
13363
+ logger$b.info('Engine check starting');
13269
13364
 
13270
13365
  for (let i = 0; i < this.checks.length; i++) {
13271
13366
  const { name, check } = this.checks[i];
13272
13367
 
13273
- logger$1.info(`Checking ${name} ...`);
13368
+ logger$b.info(`Checking ${name} ...`);
13274
13369
 
13275
13370
  onCheckBegin(name);
13276
13371
  try {
13277
13372
  // eslint-disable-next-line no-await-in-loop
13278
13373
  const result = await check(this.server, this.session, this.externalAppConfig);
13279
- logger$1.info(`Checking ${name} success.`, { result });
13374
+ logger$b.info(`Checking ${name} success.`, { result });
13280
13375
 
13281
13376
  onCheckResult(name, result);
13282
13377
  } catch (e) {
13283
- logger$1.info(`Checking ${name} failure`, { message: e.message });
13378
+ logger$b.info(`Checking ${name} failure`, { message: e.message });
13284
13379
 
13285
13380
  onCheckResult(name, e);
13286
13381
  }
13287
13382
  }
13288
13383
 
13289
- logger$1.info('Engine check done.');
13384
+ logger$b.info('Engine check done.');
13290
13385
  }
13291
13386
 
13292
13387
  addCheck(check ) {
@@ -13310,7 +13405,7 @@ const Wazo = {
13310
13405
  Auth: Auth$1,
13311
13406
  Phone: Phone$1,
13312
13407
  Websocket: Websocket$1,
13313
- Room: Room$1,
13408
+ Room,
13314
13409
  SipRoom,
13315
13410
  RemoteParticipant,
13316
13411
  LocalParticipant,
@@ -13343,7 +13438,7 @@ const Wazo = {
13343
13438
  Session,
13344
13439
  Voicemail,
13345
13440
  Relocation,
13346
- ConferenceRoom: Room,
13441
+ ConferenceRoom: Room$1,
13347
13442
  CallSession,
13348
13443
  IndirectTransfer,
13349
13444
  SwitchboardCall,
@@ -13382,7 +13477,7 @@ if (global) {
13382
13477
  class InvalidSubscription extends Error {}
13383
13478
  class InvalidAuthorization extends Error {}
13384
13479
 
13385
- const logger = IssueReporter$1.loggerFor('simple-auth');
13480
+ const logger$c = IssueReporter$1.loggerFor('simple-auth');
13386
13481
 
13387
13482
  class Auth {
13388
13483
 
@@ -13417,7 +13512,7 @@ class Auth {
13417
13512
  setApiClientId(this.clientId);
13418
13513
  setRefreshExpiration(this.expiration);
13419
13514
  setOnRefreshToken((token , session ) => {
13420
- logger.info('on refresh token done', { token });
13515
+ logger$c.info('on refresh token done', { token });
13421
13516
  setApiToken(token);
13422
13517
  Wazo.Websocket.updateToken(token);
13423
13518
 
@@ -13462,7 +13557,7 @@ class Auth {
13462
13557
  const rawSession = await getApiClient().auth.authenticate(token);
13463
13558
  return this._onAuthenticated(rawSession);
13464
13559
  } catch (e) {
13465
- logger.error('on validate token error', e);
13560
+ logger$c.error('on validate token error', e);
13466
13561
  console.warn(e);
13467
13562
  return false;
13468
13563
  }