@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);
@@ -5452,7 +5526,7 @@ var getApiClient = (forServer ) => {
5452
5526
  class InvalidSubscription extends Error {}
5453
5527
  class InvalidAuthorization extends Error {}
5454
5528
 
5455
- const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5529
+ const logger$3 = IssueReporter$1.loggerFor('simple-auth');
5456
5530
 
5457
5531
  class Auth {
5458
5532
 
@@ -5487,7 +5561,7 @@ class Auth {
5487
5561
  setApiClientId(this.clientId);
5488
5562
  setRefreshExpiration(this.expiration);
5489
5563
  setOnRefreshToken((token , session ) => {
5490
- logger$9.info('on refresh token done', { token });
5564
+ logger$3.info('on refresh token done', { token });
5491
5565
  setApiToken(token);
5492
5566
  Wazo.Websocket.updateToken(token);
5493
5567
 
@@ -5532,7 +5606,7 @@ class Auth {
5532
5606
  const rawSession = await getApiClient().auth.authenticate(token);
5533
5607
  return this._onAuthenticated(rawSession);
5534
5608
  } catch (e) {
5535
- logger$9.error('on validate token error', e);
5609
+ logger$3.error('on validate token error', e);
5536
5610
  console.warn(e);
5537
5611
  return false;
5538
5612
  }
@@ -5888,7 +5962,7 @@ class AdHocAPIConference {
5888
5962
 
5889
5963
  /* */
5890
5964
 
5891
- const parseCandidate$1 = (candidate ) => {
5965
+ const parseCandidate = (candidate ) => {
5892
5966
  if (!candidate) {
5893
5967
  return null;
5894
5968
  }
@@ -5901,10 +5975,6 @@ const getSrflxOrRelay = (candidates ) =>
5901
5975
  candidates
5902
5976
  .filter(candidate => candidate && (candidate.type === 'srflx' || candidate.type === 'relay'));
5903
5977
 
5904
- const areCandidateValid = (candidates ) =>
5905
- getSrflxOrRelay(candidates)
5906
- .length > 0;
5907
-
5908
5978
  const getVideoDirection = (sdp ) => {
5909
5979
  const parsedSdp = sdpParser__default['default'].parse(sdp);
5910
5980
  const videoMedia = parsedSdp.media.find(media => media.type === 'video');
@@ -5957,8 +6027,6 @@ const fixSdp = (sdp , candidates , forcePort = true)
5957
6027
  /* global RTCSessionDescriptionInit, navigator */
5958
6028
 
5959
6029
  const wazoLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-sdh') : console;
5960
- const MAX_WAIT_FOR_ICE_TRIES = 20;
5961
- const WAIT_FOR_ICE_TIMEOUT = 500;
5962
6030
 
5963
6031
  // Customized mediaStreamFactory allowing to send screensharing stream directory when upgrading
5964
6032
  const wazoMediaStreamFactory = (constraints ) => {
@@ -6048,7 +6116,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6048
6116
  this.peerConnectionDelegate.onicecandidate = event => {
6049
6117
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6050
6118
  if (event.candidate) {
6051
- this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6119
+ this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
6052
6120
  }
6053
6121
  };
6054
6122
 
@@ -6148,38 +6216,6 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6148
6216
  this._peerConnection = undefined;
6149
6217
  }
6150
6218
 
6151
- async _waitForValidGatheredIce() {
6152
- let tries = 0;
6153
-
6154
- while (!areCandidateValid(this.gatheredCandidates) && tries < MAX_WAIT_FOR_ICE_TRIES) {
6155
- wazoLogger.trace('SessionDescriptionHandler._waitForValidGatheredIce, waiting for ice', {
6156
- tries,
6157
- max: MAX_WAIT_FOR_ICE_TRIES,
6158
- });
6159
-
6160
- tries++;
6161
-
6162
- // eslint-disable-next-line no-await-in-loop
6163
- await new Promise(resolve => setTimeout(resolve, WAIT_FOR_ICE_TIMEOUT));
6164
- }
6165
-
6166
- if (tries >= MAX_WAIT_FOR_ICE_TRIES) {
6167
- const errorMsg = 'No valid candidates found, can\'t answer the call';
6168
- const error = new Error(errorMsg);
6169
- wazoLogger.error(errorMsg, { tries, max: MAX_WAIT_FOR_ICE_TRIES });
6170
-
6171
- // Emit an error, because sip.js catches the exception and switch to status Terminated.
6172
- this.eventEmitter.emit('error', error);
6173
-
6174
- wazoLogger.error('No valid candidates found', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6175
- }
6176
-
6177
- // eslint-disable-next-line
6178
- wazoLogger.trace('Found valid candidates', { tries, candidates: JSON.stringify(this.gatheredCandidates) });
6179
-
6180
- return this.getLocalSessionDescription();
6181
- }
6182
-
6183
6219
  // Overridden to send `inactive` in conference
6184
6220
  updateDirection(options , isConference = false,
6185
6221
  audioOnly = false) {
@@ -6544,7 +6580,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6544
6580
  const SEND_STATS_DELAY = 5000;
6545
6581
 
6546
6582
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6547
- const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6583
+ const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6548
6584
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6549
6585
 
6550
6586
  // events
@@ -6558,14 +6594,14 @@ const TRANSPORT_ERROR = 'transportError';
6558
6594
  const MESSAGE = 'message';
6559
6595
  const ACCEPTED = 'accepted';
6560
6596
  const REJECTED = 'rejected';
6561
- const ON_TRACK$1 = 'onTrack';
6562
- const ON_REINVITE$1 = 'reinvite';
6597
+ const ON_TRACK = 'onTrack';
6598
+ const ON_REINVITE = 'reinvite';
6563
6599
  const ON_ERROR = 'onError';
6564
6600
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6565
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
6566
- const ON_DISCONNECTED$1 = 'onDisconnected';
6601
+ const ON_NETWORK_STATS = 'onNetworkStats';
6602
+ const ON_DISCONNECTED = 'onDisconnected';
6567
6603
 
6568
- const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6604
+ const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6569
6605
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6570
6606
  class CanceledCallError extends Error {}
6571
6607
 
@@ -6701,12 +6737,12 @@ class WebRTCClient extends Emitter {
6701
6737
  this.MESSAGE = MESSAGE;
6702
6738
  this.ACCEPTED = ACCEPTED;
6703
6739
  this.REJECTED = REJECTED;
6704
- this.ON_TRACK = ON_TRACK$1;
6705
- this.ON_REINVITE = ON_REINVITE$1;
6740
+ this.ON_TRACK = ON_TRACK;
6741
+ this.ON_REINVITE = ON_REINVITE;
6706
6742
  this.ON_ERROR = ON_ERROR;
6707
6743
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6708
- this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6709
- this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6744
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6745
+ this.ON_DISCONNECTED = ON_DISCONNECTED;
6710
6746
  }
6711
6747
 
6712
6748
  configureMedia(media ) {
@@ -6723,13 +6759,13 @@ class WebRTCClient extends Emitter {
6723
6759
 
6724
6760
  createUserAgent(configOverrides ) {
6725
6761
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6726
- logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6762
+ logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
6727
6763
 
6728
6764
  webRTCConfiguration.delegate = {
6729
6765
  onConnect: this.onConnect.bind(this),
6730
6766
  onDisconnect: this.onDisconnect.bind(this),
6731
6767
  onInvite: (invitation ) => {
6732
- logger$8.info('sdk webrtc on invite', {
6768
+ logger$4.info('sdk webrtc on invite', {
6733
6769
  method: 'delegate.onInvite',
6734
6770
  id: invitation.id,
6735
6771
  remoteURI: invitation.remoteURI,
@@ -6772,7 +6808,7 @@ class WebRTCClient extends Emitter {
6772
6808
  }
6773
6809
 
6774
6810
  onConnect() {
6775
- logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6811
+ logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6776
6812
  this.eventEmitter.emit(CONNECTED);
6777
6813
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6778
6814
  this.registerer.waitingToggle(false);
@@ -6781,7 +6817,7 @@ class WebRTCClient extends Emitter {
6781
6817
  }
6782
6818
 
6783
6819
  async onDisconnect(error ) {
6784
- logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6820
+ logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6785
6821
  this.connectionPromise = null;
6786
6822
  // The UA will attempt to reconnect automatically when an error occurred
6787
6823
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6806,37 +6842,37 @@ class WebRTCClient extends Emitter {
6806
6842
  };
6807
6843
 
6808
6844
  if (this.skipRegister) {
6809
- logger$8.info('sdk webrtc skip register...', logInfo);
6845
+ logger$4.info('sdk webrtc skip register...', logInfo);
6810
6846
  return Promise.resolve();
6811
6847
  }
6812
6848
 
6813
- logger$8.info('sdk webrtc registering...', logInfo);
6849
+ logger$4.info('sdk webrtc registering...', logInfo);
6814
6850
 
6815
6851
  if (!this.userAgent) {
6816
- logger$8.info('sdk webrtc recreating User Agent');
6852
+ logger$4.info('sdk webrtc recreating User Agent');
6817
6853
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6818
6854
  }
6819
6855
  if (!this.userAgent || this.isRegistered()) {
6820
- logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6856
+ logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
6821
6857
  return Promise.resolve();
6822
6858
  }
6823
6859
 
6824
6860
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6825
- logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6861
+ logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
6826
6862
  return Promise.resolve();
6827
6863
  }
6828
6864
 
6829
6865
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6830
6866
 
6831
6867
  const onRegisterFailed = () => {
6832
- logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6868
+ logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6833
6869
  this.connectionPromise = null;
6834
6870
  if (this.registerer && this.registerer.waiting) {
6835
6871
  this.registerer.waitingToggle(false);
6836
6872
  }
6837
6873
 
6838
6874
  if (tries <= MAX_REGISTER_TRIES) {
6839
- logger$8.info('sdk webrtc registering, retrying...', { tries });
6875
+ logger$4.info('sdk webrtc registering, retrying...', { tries });
6840
6876
  setTimeout(() => this.register(tries + 1), 300);
6841
6877
  }
6842
6878
  };
@@ -6845,18 +6881,18 @@ class WebRTCClient extends Emitter {
6845
6881
  // Avoid race condition with the close method called just before register and setting userAgent to null
6846
6882
  // during the resolution of the primise.
6847
6883
  if (!this.userAgent) {
6848
- logger$8.info('sdk webrtc recreating User Agent after connection');
6884
+ logger$4.info('sdk webrtc recreating User Agent after connection');
6849
6885
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6850
6886
  }
6851
6887
 
6852
- logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6888
+ logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6853
6889
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6854
6890
  this.connectionPromise = null;
6855
6891
  this._monkeyPatchRegisterer(this.registerer);
6856
6892
 
6857
6893
  // Bind registerer events
6858
6894
  this.registerer.stateChange.addListener(newState => {
6859
- logger$8.info('sdk webrtc registering, state changed', { newState });
6895
+ logger$4.info('sdk webrtc registering, state changed', { newState });
6860
6896
 
6861
6897
  if (newState === registererState.RegistererState.Registered && this.registerer
6862
6898
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6869,7 +6905,7 @@ class WebRTCClient extends Emitter {
6869
6905
  const options = {
6870
6906
  requestDelegate: {
6871
6907
  onReject: response => {
6872
- logger$8.error('sdk webrtc registering, rejected', { response });
6908
+ logger$4.error('sdk webrtc registering, rejected', { response });
6873
6909
 
6874
6910
  onRegisterFailed();
6875
6911
  },
@@ -6877,13 +6913,13 @@ class WebRTCClient extends Emitter {
6877
6913
  };
6878
6914
 
6879
6915
  return this.registerer.register(options).catch((e) => {
6880
- logger$8.error('sdk webrtc registering, error', e);
6916
+ logger$4.error('sdk webrtc registering, error', e);
6881
6917
 
6882
6918
  this.eventEmitter.emit(REGISTRATION_FAILED);
6883
6919
  return e;
6884
6920
  });
6885
6921
  }).catch(error => {
6886
- logger$8.error('sdk webrtc registering, transport error', error);
6922
+ logger$4.error('sdk webrtc registering, transport error', error);
6887
6923
  onRegisterFailed();
6888
6924
  });
6889
6925
  }
@@ -6912,21 +6948,21 @@ class WebRTCClient extends Emitter {
6912
6948
  }
6913
6949
 
6914
6950
  unregister() {
6915
- logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6951
+ logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6916
6952
  if (!this.registerer) {
6917
6953
  return Promise.resolve();
6918
6954
  }
6919
6955
 
6920
6956
  try {
6921
6957
  return this.registerer.unregister().then(() => {
6922
- logger$8.info('sdk webrtc unregistered');
6958
+ logger$4.info('sdk webrtc unregistered');
6923
6959
  this._cleanupRegister();
6924
6960
  }).catch(e => {
6925
- logger$8.error('sdk webrtc unregistering, promise error', e);
6961
+ logger$4.error('sdk webrtc unregistering, promise error', e);
6926
6962
  this._cleanupRegister();
6927
6963
  });
6928
6964
  } catch (e) {
6929
- logger$8.error('sdk webrtc unregistering, error', e);
6965
+ logger$4.error('sdk webrtc unregistering, error', e);
6930
6966
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6931
6967
  // error when the registerer is in a bad state
6932
6968
  this._cleanupRegister();
@@ -6934,7 +6970,7 @@ class WebRTCClient extends Emitter {
6934
6970
  }
6935
6971
 
6936
6972
  stop() {
6937
- logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6973
+ logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6938
6974
  if (!this.userAgent) {
6939
6975
  return Promise.resolve();
6940
6976
  }
@@ -6942,12 +6978,12 @@ class WebRTCClient extends Emitter {
6942
6978
  return this.userAgent.stop().then(() => {
6943
6979
  return this._cleanupRegister();
6944
6980
  }).catch(e => {
6945
- logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6981
+ logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6946
6982
  });
6947
6983
  }
6948
6984
 
6949
6985
  call(number , enableVideo , audioOnly = false, conference = false) {
6950
- logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6986
+ logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6951
6987
  const inviterOptions = {
6952
6988
  sessionDescriptionHandlerOptionsReInvite: {
6953
6989
  conference,
@@ -6972,11 +7008,13 @@ class WebRTCClient extends Emitter {
6972
7008
  const inviteOptions = {
6973
7009
  requestDelegate: {
6974
7010
  onAccept: (response ) => {
6975
- session.sessionDescriptionHandler.peerConnection.sfu = conference;
7011
+ if (session.sessionDescriptionHandler.peerConnection) {
7012
+ session.sessionDescriptionHandler.peerConnection.sfu = conference;
7013
+ }
6976
7014
  this._onAccepted(session, response.session, true);
6977
7015
  },
6978
7016
  onReject: (response ) => {
6979
- logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7017
+ logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6980
7018
  this._stopSendingStats(session);
6981
7019
  this.stopNetworkMonitoring(session);
6982
7020
 
@@ -6999,11 +7037,11 @@ class WebRTCClient extends Emitter {
6999
7037
  }
7000
7038
 
7001
7039
  answer(session , enableVideo ) {
7002
- logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
7040
+ logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
7003
7041
 
7004
7042
  if (!session || !session.accept) {
7005
7043
  const error = 'No session to answer, or not an invitation';
7006
- logger$8.warn(error);
7044
+ logger$4.warn(error);
7007
7045
  return Promise.reject(new Error(error));
7008
7046
  }
7009
7047
  const options = {
@@ -7013,15 +7051,15 @@ class WebRTCClient extends Emitter {
7013
7051
  return session.accept(options).then(() => {
7014
7052
  if (session.isCanceled) {
7015
7053
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
7016
- logger$8.error(message, { id: session.id });
7054
+ logger$4.error(message, { id: session.id });
7017
7055
  this.onCallEnded(session);
7018
7056
 
7019
7057
  throw new CanceledCallError(message);
7020
7058
  }
7021
- logger$8.info('sdk webrtc answer, accepted.');
7059
+ logger$4.info('sdk webrtc answer, accepted.');
7022
7060
  this._onAccepted(session);
7023
7061
  }).catch(e => {
7024
- logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7062
+ logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7025
7063
 
7026
7064
  throw e;
7027
7065
  });
@@ -7029,7 +7067,7 @@ class WebRTCClient extends Emitter {
7029
7067
 
7030
7068
  hangup(session ) {
7031
7069
  const { state, id } = session;
7032
- logger$8.info('sdk webrtc hangup call', { id, state });
7070
+ logger$4.info('sdk webrtc hangup call', { id, state });
7033
7071
 
7034
7072
  try {
7035
7073
  this._stopSendingStats(session);
@@ -7058,7 +7096,7 @@ class WebRTCClient extends Emitter {
7058
7096
 
7059
7097
  return bye();
7060
7098
  } catch (error) {
7061
- logger$8.warn('sdk webrtc hangup, error', error);
7099
+ logger$4.warn('sdk webrtc hangup, error', error);
7062
7100
  }
7063
7101
 
7064
7102
  return null;
@@ -7076,7 +7114,7 @@ class WebRTCClient extends Emitter {
7076
7114
  // Fetch and emit an event at `interval` with session network stats
7077
7115
  startNetworkMonitoring(session , interval = 1000) {
7078
7116
  const sessionId = this.getSipSessionId(session);
7079
- logger$8.info('starting network inspection', { id: sessionId });
7117
+ logger$4.info('starting network inspection', { id: sessionId });
7080
7118
 
7081
7119
  this.sessionNetworkStats[sessionId] = [];
7082
7120
 
@@ -7086,7 +7124,7 @@ class WebRTCClient extends Emitter {
7086
7124
  stopNetworkMonitoring(session ) {
7087
7125
  const sessionId = this.getSipSessionId(session);
7088
7126
  const exists = sessionId in this.networkMonitoringInterval;
7089
- logger$8.info('stopping network inspection', { id: sessionId, exists });
7127
+ logger$4.info('stopping network inspection', { id: sessionId, exists });
7090
7128
 
7091
7129
  if (exists) {
7092
7130
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -7096,17 +7134,17 @@ class WebRTCClient extends Emitter {
7096
7134
  }
7097
7135
 
7098
7136
  reject(session ) {
7099
- logger$8.info('sdk webrtc reject call', { id: session.id });
7137
+ logger$4.info('sdk webrtc reject call', { id: session.id });
7100
7138
 
7101
7139
  try {
7102
7140
  return session.reject ? session.reject() : session.cancel();
7103
7141
  } catch (e) {
7104
- logger$8.warn('Error when rejecting call', e.message, e.stack);
7142
+ logger$4.warn('Error when rejecting call', e.message, e.stack);
7105
7143
  }
7106
7144
  }
7107
7145
 
7108
7146
  async close() {
7109
- logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7147
+ logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7110
7148
  this._cleanupMedia();
7111
7149
  this.connectionPromise = null;
7112
7150
 
@@ -7137,7 +7175,7 @@ class WebRTCClient extends Emitter {
7137
7175
  // eg: "INVITE not rejectable in state Completed"
7138
7176
  }
7139
7177
  this.userAgent = null;
7140
- logger$8.info('sdk webrtc client closed');
7178
+ logger$4.info('sdk webrtc client closed');
7141
7179
  }
7142
7180
 
7143
7181
  getNumber(session ) {
@@ -7150,13 +7188,13 @@ class WebRTCClient extends Emitter {
7150
7188
  }
7151
7189
 
7152
7190
  mute(session ) {
7153
- logger$8.info('sdk webrtc mute', { id: session.id });
7191
+ logger$4.info('sdk webrtc mute', { id: session.id });
7154
7192
 
7155
7193
  this._toggleAudio(session, true);
7156
7194
  }
7157
7195
 
7158
7196
  unmute(session ) {
7159
- logger$8.info('sdk webrtc unmute', { id: session.id });
7197
+ logger$4.info('sdk webrtc unmute', { id: session.id });
7160
7198
 
7161
7199
  this._toggleAudio(session, false);
7162
7200
  }
@@ -7196,13 +7234,13 @@ class WebRTCClient extends Emitter {
7196
7234
  }
7197
7235
 
7198
7236
  toggleCameraOn(session ) {
7199
- logger$8.info('sdk webrtc toggle camera on', { id: session.id });
7237
+ logger$4.info('sdk webrtc toggle camera on', { id: session.id });
7200
7238
 
7201
7239
  this._toggleVideo(session, false);
7202
7240
  }
7203
7241
 
7204
7242
  toggleCameraOff(session ) {
7205
- logger$8.info('sdk webrtc toggle camera off', { id: session.id });
7243
+ logger$4.info('sdk webrtc toggle camera off', { id: session.id });
7206
7244
 
7207
7245
  this._toggleVideo(session, true);
7208
7246
  }
@@ -7211,7 +7249,7 @@ class WebRTCClient extends Emitter {
7211
7249
  const sessionId = this.getSipSessionId(session);
7212
7250
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
7213
7251
 
7214
- logger$8.info('sdk webrtc hold', {
7252
+ logger$4.info('sdk webrtc hold', {
7215
7253
  sessionId,
7216
7254
  keys: Object.keys(this.heldSessions),
7217
7255
  pendingReinvite: !!session.pendingReinvite,
@@ -7260,7 +7298,7 @@ class WebRTCClient extends Emitter {
7260
7298
  const sessionId = this.getSipSessionId(session);
7261
7299
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7262
7300
 
7263
- logger$8.info('sdk webrtc unhold', {
7301
+ logger$4.info('sdk webrtc unhold', {
7264
7302
  sessionId,
7265
7303
  keys: Object.keys(this.heldSessions),
7266
7304
  pendingReinvite: !!session.pendingReinvite,
@@ -7408,7 +7446,7 @@ class WebRTCClient extends Emitter {
7408
7446
  if (!session.sessionDescriptionHandler) {
7409
7447
  return;
7410
7448
  }
7411
- logger$8.info('Sending DTMF', {
7449
+ logger$4.info('Sending DTMF', {
7412
7450
  id: this.getSipSessionId(session),
7413
7451
  tone,
7414
7452
  });
@@ -7424,7 +7462,7 @@ class WebRTCClient extends Emitter {
7424
7462
  transfer(session , target ) {
7425
7463
  this.hold(session);
7426
7464
 
7427
- logger$8.info('Transfering a session', {
7465
+ logger$4.info('Transfering a session', {
7428
7466
  id: this.getSipSessionId(session),
7429
7467
  target,
7430
7468
  });
@@ -7446,17 +7484,17 @@ class WebRTCClient extends Emitter {
7446
7484
  atxfer(session ) {
7447
7485
  this.hold(session);
7448
7486
 
7449
- logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7487
+ logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7450
7488
 
7451
7489
  const result = {
7452
7490
  newSession: null,
7453
7491
  init: async (target ) => {
7454
- logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7492
+ logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7455
7493
 
7456
7494
  result.newSession = await this.call(target);
7457
7495
  },
7458
7496
  complete: () => {
7459
- logger$8.info('webrtc transfer completed', {
7497
+ logger$4.info('webrtc transfer completed', {
7460
7498
  id: this.getSipSessionId(session),
7461
7499
  referId: this.getSipSessionId(result.newSession),
7462
7500
  });
@@ -7477,7 +7515,7 @@ class WebRTCClient extends Emitter {
7477
7515
  return;
7478
7516
  }
7479
7517
 
7480
- logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7518
+ logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
7481
7519
 
7482
7520
  try {
7483
7521
  sipSession.message({
@@ -7519,7 +7557,7 @@ class WebRTCClient extends Emitter {
7519
7557
  }
7520
7558
 
7521
7559
  changeAudioOutputVolume(volume ) {
7522
- logger$8.info('Changing audio output volume', { volume });
7560
+ logger$4.info('Changing audio output volume', { volume });
7523
7561
 
7524
7562
  Object.values(this.audioElements).forEach(audioElement => {
7525
7563
  if (audioElement instanceof HTMLAudioElement) {
@@ -7531,7 +7569,7 @@ class WebRTCClient extends Emitter {
7531
7569
  }
7532
7570
 
7533
7571
  changeAudioOutputDevice(id ) {
7534
- logger$8.info('Changing audio output device', { id });
7572
+ logger$4.info('Changing audio output device', { id });
7535
7573
 
7536
7574
  Object.values(this.audioElements).forEach(audioElement => {
7537
7575
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7548,7 +7586,7 @@ class WebRTCClient extends Emitter {
7548
7586
 
7549
7587
  changeAudioInputDevice(id , session ) {
7550
7588
  const currentId = this.getAudioDeviceId();
7551
- logger$8.info('setting audio input device', { id, currentId, session: !!session });
7589
+ logger$4.info('setting audio input device', { id, currentId, session: !!session });
7552
7590
 
7553
7591
  if (id === currentId) {
7554
7592
  return null;
@@ -7594,7 +7632,7 @@ class WebRTCClient extends Emitter {
7594
7632
 
7595
7633
  setVideoInputDevice(id ) {
7596
7634
  const currentId = this.getVideoDeviceId();
7597
- logger$8.info('setting video input device', { id, currentId });
7635
+ logger$4.info('setting video input device', { id, currentId });
7598
7636
 
7599
7637
  if (id === currentId) {
7600
7638
  return null;
@@ -7619,7 +7657,7 @@ class WebRTCClient extends Emitter {
7619
7657
  const sessionId = this.getSipSessionId(session);
7620
7658
  const localStream = this.getLocalStream(sessionId);
7621
7659
 
7622
- logger$8.info('changing video input device', { id, sessionId });
7660
+ logger$4.info('changing video input device', { id, sessionId });
7623
7661
 
7624
7662
  // Release old video stream
7625
7663
  if (localStream) {
@@ -7687,7 +7725,7 @@ class WebRTCClient extends Emitter {
7687
7725
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7688
7726
  const desktop = newConstraints && newConstraints.desktop;
7689
7727
 
7690
- logger$8.info('Sending reinvite', {
7728
+ logger$4.info('Sending reinvite', {
7691
7729
  id: this.getSipSessionId(sipSession),
7692
7730
  newConstraints,
7693
7731
  conference,
@@ -7725,7 +7763,7 @@ class WebRTCClient extends Emitter {
7725
7763
  sipSession.incomingInviteRequest.message.body = response.message.body;
7726
7764
  }
7727
7765
 
7728
- logger$8.info('on re-INVITE accepted', {
7766
+ logger$4.info('on re-INVITE accepted', {
7729
7767
  id: this.getSipSessionId(sipSession),
7730
7768
  wasMuted,
7731
7769
  shouldDoScreenSharing,
@@ -7743,7 +7781,7 @@ class WebRTCClient extends Emitter {
7743
7781
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7744
7782
  }
7745
7783
 
7746
- return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7784
+ return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7747
7785
  },
7748
7786
  },
7749
7787
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7844,6 +7882,16 @@ class WebRTCClient extends Emitter {
7844
7882
  return this.hasRemoteVideo(sessionId) ? this.getRemoteStream(sessionId) : null;
7845
7883
  }
7846
7884
 
7885
+ // Useful in a react-native environment when remoteMediaStream is not updated
7886
+ getRemoteVideoStreamFromPc(sessionId ) {
7887
+ const pc = this.getPeerConnection(sessionId);
7888
+ if (!pc) {
7889
+ return null;
7890
+ }
7891
+
7892
+ return pc.getRemoteStreams().find(stream => !!stream.getVideoTracks().length);
7893
+ }
7894
+
7847
7895
  hasVideo(sessionId ) {
7848
7896
  return this.hasLocalVideo(sessionId) || this.hasRemoteVideo(sessionId);
7849
7897
  }
@@ -7890,7 +7938,7 @@ class WebRTCClient extends Emitter {
7890
7938
  }
7891
7939
 
7892
7940
  startHeartbeat() {
7893
- logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7941
+ logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7894
7942
  if (!this.userAgent) {
7895
7943
  this.heartbeat.stop();
7896
7944
  return;
@@ -7903,7 +7951,7 @@ class WebRTCClient extends Emitter {
7903
7951
  }
7904
7952
 
7905
7953
  stopHeartbeat() {
7906
- logger$8.info('sdk webrtc stop heartbeat');
7954
+ logger$4.info('sdk webrtc stop heartbeat');
7907
7955
  this.heartbeat.stop();
7908
7956
  }
7909
7957
 
@@ -7924,7 +7972,7 @@ class WebRTCClient extends Emitter {
7924
7972
  }
7925
7973
 
7926
7974
  attemptReconnection() {
7927
- logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7975
+ logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
7928
7976
  if (!this.userAgent) {
7929
7977
  return;
7930
7978
  }
@@ -7949,7 +7997,7 @@ class WebRTCClient extends Emitter {
7949
7997
  return;
7950
7998
  }
7951
7999
 
7952
- logger$8.info('setting local media stream', {
8000
+ logger$4.info('setting local media stream', {
7953
8001
  sipSessionId,
7954
8002
  tracks: newStream ? newStream.getTracks() : null,
7955
8003
  });
@@ -7966,7 +8014,7 @@ class WebRTCClient extends Emitter {
7966
8014
 
7967
8015
  const oldStream = this.getLocalStream(sipSessionId);
7968
8016
 
7969
- logger$8.info('updating local stream', {
8017
+ logger$4.info('updating local stream', {
7970
8018
  sipSessionId,
7971
8019
  oldStream: !!oldStream,
7972
8020
  tracks: newStream.getTracks(),
@@ -7986,7 +8034,7 @@ class WebRTCClient extends Emitter {
7986
8034
  const remoteStream = this.getRemoteStream(sessionId);
7987
8035
  const pc = this.getPeerConnection(sessionId);
7988
8036
 
7989
- logger$8.info('Updating remote stream', {
8037
+ logger$4.info('Updating remote stream', {
7990
8038
  sessionId,
7991
8039
  tracks: remoteStream ? remoteStream.getTracks() : null,
7992
8040
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -8012,7 +8060,7 @@ class WebRTCClient extends Emitter {
8012
8060
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
8013
8061
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
8014
8062
 
8015
- logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8063
+ logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8016
8064
 
8017
8065
  return {
8018
8066
  constraints: {
@@ -8061,7 +8109,7 @@ class WebRTCClient extends Emitter {
8061
8109
  }
8062
8110
 
8063
8111
  _onTransportError() {
8064
- logger$8.error('on transport error');
8112
+ logger$4.error('on transport error');
8065
8113
  this.eventEmitter.emit(TRANSPORT_ERROR);
8066
8114
  this.attemptReconnection();
8067
8115
  }
@@ -8070,7 +8118,7 @@ class WebRTCClient extends Emitter {
8070
8118
  const body = message && typeof message === 'object' ? message.data : message;
8071
8119
  if (body && body.indexOf('200 OK') !== -1) {
8072
8120
  if (this.hasHeartbeat()) {
8073
- logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8121
+ logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8074
8122
 
8075
8123
  this.heartbeat.onHeartbeat();
8076
8124
  if (this.heartbeatCb) {
@@ -8081,7 +8129,7 @@ class WebRTCClient extends Emitter {
8081
8129
  }
8082
8130
 
8083
8131
  async _onHeartbeatTimeout() {
8084
- logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8132
+ logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8085
8133
 
8086
8134
  if (this.heartbeatTimeoutCb) {
8087
8135
  this.heartbeatTimeoutCb();
@@ -8093,7 +8141,7 @@ class WebRTCClient extends Emitter {
8093
8141
  try {
8094
8142
  await this.userAgent.transport.disconnect();
8095
8143
  } catch (e) {
8096
- logger$8.error('Transport disconnection after heartbeat timeout, error', e);
8144
+ logger$4.error('Transport disconnection after heartbeat timeout, error', e);
8097
8145
  }
8098
8146
  }
8099
8147
 
@@ -8126,31 +8174,31 @@ class WebRTCClient extends Emitter {
8126
8174
  }
8127
8175
 
8128
8176
  _connectIfNeeded() {
8129
- logger$8.info('connect if needed, checking', { connected: this.isConnected() });
8177
+ logger$4.info('connect if needed, checking', { connected: this.isConnected() });
8130
8178
  if (!this.userAgent) {
8131
- logger$8.info('need to recreate User Agent');
8179
+ logger$4.info('need to recreate User Agent');
8132
8180
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
8133
8181
  }
8134
8182
 
8135
8183
  if (this.isConnected()) {
8136
- logger$8.info('webrtc sdk, already connected');
8184
+ logger$4.info('webrtc sdk, already connected');
8137
8185
  return Promise.resolve();
8138
8186
  }
8139
8187
 
8140
8188
  if (this.isConnecting()) {
8141
- logger$8.info('webrtc sdk, already connecting...');
8189
+ logger$4.info('webrtc sdk, already connecting...');
8142
8190
 
8143
8191
  this.connectionPromise = this.userAgent.transport.connectPromise;
8144
8192
  return this.connectionPromise;
8145
8193
  }
8146
8194
 
8147
8195
  if (this.connectionPromise) {
8148
- logger$8.info('webrtc sdk, connection promise connecting...');
8196
+ logger$4.info('webrtc sdk, connection promise connecting...');
8149
8197
  // $FlowFixMe
8150
8198
  return this.connectionPromise;
8151
8199
  }
8152
8200
 
8153
- logger$8.info('WebRTC UA needs to connect');
8201
+ logger$4.info('WebRTC UA needs to connect');
8154
8202
 
8155
8203
  // Force UA to reconnect
8156
8204
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8275,7 +8323,7 @@ class WebRTCClient extends Emitter {
8275
8323
 
8276
8324
  sdh.peerConnectionDelegate = {
8277
8325
  onicecandidateerror: (error ) => {
8278
- logger$8.error('on icecandidate error', {
8326
+ logger$4.error('on icecandidate error', {
8279
8327
  address: error.address,
8280
8328
  port: error.port,
8281
8329
  errorCode: error.errorCode,
@@ -8304,7 +8352,7 @@ class WebRTCClient extends Emitter {
8304
8352
  updatedNumber = session.assertedIdentity.uri.normal.user;
8305
8353
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8306
8354
  }
8307
- logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8355
+ logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8308
8356
 
8309
8357
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8310
8358
 
@@ -8320,12 +8368,12 @@ class WebRTCClient extends Emitter {
8320
8368
 
8321
8369
  this._setupMedias(session);
8322
8370
 
8323
- return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8371
+ return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8324
8372
  };
8325
8373
  }
8326
8374
 
8327
8375
  _onAccepted(session , sessionDialog , withEvent = true) {
8328
- logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8376
+ logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8329
8377
 
8330
8378
  this.storeSipSession(session);
8331
8379
 
@@ -8337,14 +8385,14 @@ class WebRTCClient extends Emitter {
8337
8385
  const onTrack = (event ) => {
8338
8386
  const isAudioOnly = this._isAudioOnly(session);
8339
8387
  const { kind, label, readyState, id, muted } = event.track;
8340
- logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8388
+ logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8341
8389
 
8342
8390
  // Stop video track in audio only mode
8343
8391
  if (isAudioOnly && kind === 'video') {
8344
8392
  event.track.stop();
8345
8393
  }
8346
8394
 
8347
- this.eventEmitter.emit(ON_TRACK$1, session, event);
8395
+ this.eventEmitter.emit(ON_TRACK, session, event);
8348
8396
  };
8349
8397
 
8350
8398
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8354,8 +8402,9 @@ class WebRTCClient extends Emitter {
8354
8402
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8355
8403
 
8356
8404
  pc.oniceconnectionstatechange = () => {
8405
+ logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
8357
8406
  if (pc.iceConnectionState === 'disconnected') {
8358
- this.eventEmitter.emit(ON_DISCONNECTED$1);
8407
+ this.eventEmitter.emit(ON_DISCONNECTED);
8359
8408
  }
8360
8409
  };
8361
8410
 
@@ -8526,10 +8575,10 @@ class WebRTCClient extends Emitter {
8526
8575
 
8527
8576
  _stopSendingStats(session ) {
8528
8577
  const sessionId = this.getSipSessionId(session);
8529
- logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8578
+ logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8530
8579
 
8531
8580
  if (sessionId in this.statsIntervals) {
8532
- logger$8.trace('Stop sending stats for call', { sessionId });
8581
+ logger$4.trace('Stop sending stats for call', { sessionId });
8533
8582
  this.statsIntervals[sessionId]();
8534
8583
  delete this.statsIntervals[sessionId];
8535
8584
  }
@@ -8545,7 +8594,7 @@ class WebRTCClient extends Emitter {
8545
8594
  try {
8546
8595
  await this.userAgent.transport.disconnect();
8547
8596
  } catch (e) {
8548
- logger$8.error('WebRTC transport disconnect, error', e);
8597
+ logger$4.error('WebRTC transport disconnect, error', e);
8549
8598
  }
8550
8599
  }
8551
8600
  }
@@ -8582,25 +8631,25 @@ class WebRTCClient extends Emitter {
8582
8631
 
8583
8632
  stats.forEach(report => {
8584
8633
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8585
- audioBytesSent += report.bytesSent + report.headerBytesSent;
8634
+ audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8586
8635
  }
8587
8636
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8588
- audioBytesSent += report.bytesSent;
8637
+ audioBytesSent += Number(report.bytesSent);
8589
8638
  }
8590
8639
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8591
- videoBytesSent += report.bytesSent + report.headerBytesSent;
8640
+ videoBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8592
8641
  }
8593
8642
  if (report.type === 'inbound-rtp' && report.kind === 'audio') {
8594
- packetsLost += report.packetsLost;
8595
- networkStats.packetsReceived = report.packetsReceived;
8596
- audioBytesReceived += report.bytesReceived + report.headerBytesReceived;
8643
+ packetsLost += Number(report.packetsLost);
8644
+ networkStats.packetsReceived = Number(report.packetsReceived);
8645
+ audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8597
8646
  }
8598
8647
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8599
- videoBytesReceived += report.bytesReceived + report.headerBytesReceived;
8648
+ videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8600
8649
  }
8601
8650
  if (report.type === 'outbound-rtp' && report.kind === 'video') {
8602
8651
  if ('framesPerSecond' in report) {
8603
- networkStats.framesPerSecond = report.framesPerSecond;
8652
+ networkStats.framesPerSecond = Number(report.framesPerSecond);
8604
8653
  }
8605
8654
  if ('framerateMean' in report) {
8606
8655
  // framerateMean is only available in FF
@@ -8608,34 +8657,38 @@ class WebRTCClient extends Emitter {
8608
8657
  }
8609
8658
  }
8610
8659
  if (report.type === 'remote-inbound-rtp' && report.kind === 'audio') {
8611
- packetsLost += report.packetsLost;
8612
- networkStats.roundTripTime = report.roundTripTime;
8613
- networkStats.jitter = report.jitter;
8660
+ packetsLost += Number(report.packetsLost);
8661
+ networkStats.roundTripTime = Number(report.roundTripTime);
8662
+ networkStats.jitter = Number(report.jitter);
8614
8663
  }
8615
8664
  if (report.type === 'remote-inbound-rtp' && report.kind === 'video') {
8616
- packetsLost += report.packetsLost;
8665
+ packetsLost += Number(report.packetsLost);
8617
8666
  }
8618
8667
  if (report.type === 'transport') {
8619
- transportSent += report.bytesSent;
8620
- transportReceived += report.bytesReceived;
8668
+ transportSent += Number(report.bytesSent);
8669
+ transportReceived += Number(report.bytesReceived);
8621
8670
  }
8622
8671
  });
8623
8672
 
8624
8673
  networkStats.packetsLost = packetsLost;
8625
- networkStats.audioBytesSent = audioBytesSent;
8674
+ networkStats.totalAudioBytesSent = audioBytesSent;
8675
+ networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8676
+ networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8626
8677
  networkStats.audioBytesReceived = audioBytesReceived;
8627
- networkStats.videoBytesSent = videoBytesSent;
8628
- networkStats.videoBytesReceived = videoBytesReceived;
8678
+ networkStats.totalVideoBytesSent = videoBytesSent;
8679
+ networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8680
+ networkStats.totalVideoBytesReceived = videoBytesReceived;
8681
+ networkStats.videoBytesReceived = videoBytesReceived - lastVideoReceived;
8682
+ networkStats.totalTransportSent = transportSent - lastTransportSent;
8629
8683
  networkStats.transportSent = transportSent;
8630
- networkStats.transportReceived = transportReceived;
8631
-
8632
- const bandwidth = (networkStats.audioBytesSent - lastAudioSent) + (networkStats.videoBytesSent - lastVideoSent)
8633
- + (networkStats.audioBytesReceived - lastAudioReceived) + (networkStats.videoBytesReceived - lastVideoReceived)
8634
- + (networkStats.transportReceived - lastTransportReceived) + (networkStats.transportSent - lastTransportSent);
8684
+ networkStats.totalTransportReceived = transportReceived;
8685
+ networkStats.transportReceived = transportReceived - lastTransportReceived;
8635
8686
 
8636
- networkStats.bandwidth = bandwidth;
8687
+ networkStats.bandwidth = networkStats.audioBytesSent + networkStats.audioBytesReceived
8688
+ + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8689
+ + networkStats.transportSent;
8637
8690
 
8638
- this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8691
+ this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8639
8692
  this.sessionNetworkStats[sessionId].push(networkStats);
8640
8693
  }
8641
8694
 
@@ -8663,8 +8716,8 @@ const ON_CALL_FAILED = 'onCallFailed';
8663
8716
  const ON_CALL_ENDED = 'onCallEnded';
8664
8717
  const ON_CALL_ENDING = 'onCallEnding';
8665
8718
  const ON_MESSAGE = 'onMessage';
8666
- const ON_REINVITE = 'reinvite';
8667
- const ON_TRACK = 'onTrack';
8719
+ const ON_REINVITE$1 = 'reinvite';
8720
+ const ON_TRACK$1 = 'onTrack';
8668
8721
  const ON_AUDIO_STREAM = 'onAudioStream';
8669
8722
  const ON_VIDEO_STREAM = 'onVideoStream';
8670
8723
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8679,15 +8732,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8679
8732
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8680
8733
  const ON_CALL_ERROR = 'onCallError';
8681
8734
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8682
- const ON_NETWORK_STATS = 'onNetworkStats';
8735
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
8683
8736
  const ON_CHAT = 'phone/ON_CHAT';
8684
8737
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8685
- const ON_DISCONNECTED = 'onDisconnected';
8738
+ const ON_DISCONNECTED$1 = 'onDisconnected';
8686
8739
 
8687
8740
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8688
8741
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8689
8742
 
8690
- const events = [
8743
+ const events$1 = [
8691
8744
  ON_USER_AGENT,
8692
8745
  ON_REGISTERED,
8693
8746
  ON_UNREGISTERED,
@@ -8705,8 +8758,8 @@ const events = [
8705
8758
  ON_CALL_FAILED,
8706
8759
  ON_CALL_ENDED,
8707
8760
  ON_MESSAGE,
8708
- ON_REINVITE,
8709
- ON_TRACK,
8761
+ ON_REINVITE$1,
8762
+ ON_TRACK$1,
8710
8763
  ON_AUDIO_STREAM,
8711
8764
  ON_VIDEO_STREAM,
8712
8765
  ON_REMOVE_STREAM,
@@ -8721,11 +8774,11 @@ const events = [
8721
8774
  ON_CALL_ERROR,
8722
8775
  ON_CHAT,
8723
8776
  ON_SIGNAL,
8724
- ON_NETWORK_STATS,
8725
- ON_DISCONNECTED,
8777
+ ON_NETWORK_STATS$1,
8778
+ ON_DISCONNECTED$1,
8726
8779
  ];
8727
8780
 
8728
- const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8781
+ const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
8729
8782
 
8730
8783
  class WebRTCPhone extends Emitter {
8731
8784
 
@@ -8798,7 +8851,7 @@ class WebRTCPhone extends Emitter {
8798
8851
  }).catch(error => {
8799
8852
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8800
8853
  console.error('register error', error, error.message, error.stack);
8801
- logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8854
+ logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
8802
8855
  });
8803
8856
  }
8804
8857
 
@@ -8813,7 +8866,7 @@ class WebRTCPhone extends Emitter {
8813
8866
  if (!this.client) {
8814
8867
  return;
8815
8868
  }
8816
- logger$7.info('WebRTC phone stop');
8869
+ logger$5.info('WebRTC phone stop');
8817
8870
  this.client.stop();
8818
8871
  }
8819
8872
 
@@ -8828,7 +8881,7 @@ class WebRTCPhone extends Emitter {
8828
8881
  async sendReinvite(callSession , constraints = null, conference = false,
8829
8882
  audioOnly = false, iceRestart = false) {
8830
8883
  const sipSession = this.findSipSession(callSession);
8831
- logger$7.info('WebRTC phone - send reinvite', {
8884
+ logger$5.info('WebRTC phone - send reinvite', {
8832
8885
  sessionId: sipSession ? sipSession.id : null,
8833
8886
  constraints,
8834
8887
  audioOnly,
@@ -8865,7 +8918,7 @@ class WebRTCPhone extends Emitter {
8865
8918
  }
8866
8919
 
8867
8920
  startHeartbeat() {
8868
- logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8921
+ logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8869
8922
  if (!this.client || this.client.hasHeartbeat()) {
8870
8923
  return;
8871
8924
  }
@@ -8874,7 +8927,7 @@ class WebRTCPhone extends Emitter {
8874
8927
  }
8875
8928
 
8876
8929
  stopHeartbeat() {
8877
- logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8930
+ logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8878
8931
  if (!this.client) {
8879
8932
  return;
8880
8933
  }
@@ -8891,7 +8944,7 @@ class WebRTCPhone extends Emitter {
8891
8944
  }
8892
8945
 
8893
8946
  reconnect() {
8894
- logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8947
+ logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
8895
8948
  if (!this.client) {
8896
8949
  return;
8897
8950
  }
@@ -8932,10 +8985,15 @@ class WebRTCPhone extends Emitter {
8932
8985
  return false;
8933
8986
  }
8934
8987
 
8935
- logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8988
+ logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8936
8989
 
8937
8990
  this.client.downgradeToAudio(sipSession);
8938
8991
 
8992
+ if (callSession) {
8993
+ callSession.cameraEnabled = false;
8994
+ this._updateCallSession(callSession);
8995
+ }
8996
+
8939
8997
  if (withMessage) {
8940
8998
  this._sendReinviteMessage(callSession, false);
8941
8999
  }
@@ -8950,7 +9008,7 @@ class WebRTCPhone extends Emitter {
8950
9008
  return Promise.resolve(false);
8951
9009
  }
8952
9010
 
8953
- logger$7.info('Upgrade to video', {
9011
+ logger$5.info('Upgrade to video', {
8954
9012
  id: callSession ? callSession.getId() : null,
8955
9013
  constraints,
8956
9014
  isConference,
@@ -8963,6 +9021,11 @@ class WebRTCPhone extends Emitter {
8963
9021
 
8964
9022
  const newStream = await this.client.upgradeToVideo(sipSession, constraints, isConference);
8965
9023
 
9024
+ if (callSession) {
9025
+ callSession.cameraEnabled = true;
9026
+ this._updateCallSession(callSession);
9027
+ }
9028
+
8966
9029
  // If no stream is returned, it means we have to reinvite
8967
9030
  if (!newStream) {
8968
9031
  return true;
@@ -8985,7 +9048,7 @@ class WebRTCPhone extends Emitter {
8985
9048
 
8986
9049
  _sendReinviteMessage(callSession , isUpgrade ) {
8987
9050
  const sipSession = this.findSipSession(callSession);
8988
- logger$7.info('Sending reinvite message', {
9051
+ logger$5.info('Sending reinvite message', {
8989
9052
  id: callSession ? callSession.getId() : null,
8990
9053
  isUpgrade,
8991
9054
  });
@@ -9011,11 +9074,14 @@ class WebRTCPhone extends Emitter {
9011
9074
  // Monkey patch to know when canceled with the CANCEL message
9012
9075
  const onCancel = sipSession._onCancel.bind(sipSession);
9013
9076
  sipSession._onCancel = (message ) => {
9014
- logger$7.trace('on sip session canceled', { callId: message.callId });
9077
+ logger$5.trace('on sip session canceled', { callId: message.callId });
9015
9078
 
9016
9079
  onCancel(message);
9017
9080
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
9018
- this.eventEmitter.emit(ON_CALL_CANCELED, this._createCallSession(sipSession), elsewhere);
9081
+ const callSession = this._createCallSession(sipSession);
9082
+ delete this.callSessions[callSession.getId()];
9083
+
9084
+ this.eventEmitter.emit(ON_CALL_CANCELED, callSession, elsewhere);
9019
9085
  };
9020
9086
  } else if (sipSession instanceof invitation.Invitation) {
9021
9087
  console.warn('sipSession._onCancel not found, please update the wazo SDK accordingly');
@@ -9036,17 +9102,19 @@ class WebRTCPhone extends Emitter {
9036
9102
  this.audioOutputVolume,
9037
9103
  );
9038
9104
  case sessionState.SessionState.Terminating:
9039
- logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9105
+ logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9040
9106
 
9041
9107
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9042
9108
 
9043
9109
  break;
9044
9110
  case sessionState.SessionState.Terminated: {
9045
- logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9111
+ logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9046
9112
 
9113
+ // Should be called before `_onCallTerminated` or the callCount will not decrement...
9114
+ const callSession = this._createCallSession(sipSession);
9047
9115
  const wasCurrentSession = this._onCallTerminated(sipSession);
9048
9116
 
9049
- return this.eventEmitter.emit(ON_CALL_ENDED, this._createCallSession(sipSession), wasCurrentSession);
9117
+ return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
9050
9118
  }
9051
9119
  }
9052
9120
  });
@@ -9062,7 +9130,7 @@ class WebRTCPhone extends Emitter {
9062
9130
  const [stream] = event.streams;
9063
9131
  const kind = event && event.track && event.track.kind;
9064
9132
 
9065
- logger$7.info('on track stream called on the peer connection', {
9133
+ logger$5.info('on track stream called on the peer connection', {
9066
9134
  callId: this.getSipSessionId(sipSession),
9067
9135
  streamId: stream ? stream.id : null,
9068
9136
  tracks: stream ? stream.getTracks() : null,
@@ -9082,7 +9150,7 @@ class WebRTCPhone extends Emitter {
9082
9150
  };
9083
9151
 
9084
9152
  peerConnection.onremovestream = event => {
9085
- logger$7.info('on remove stream called on the peer connection', {
9153
+ logger$5.info('on remove stream called on the peer connection', {
9086
9154
  id: event.stream.id,
9087
9155
  tracks: event.stream.getTracks(),
9088
9156
  });
@@ -9092,7 +9160,7 @@ class WebRTCPhone extends Emitter {
9092
9160
  }
9093
9161
 
9094
9162
  async startScreenSharing(constraints , callSession ) {
9095
- logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9163
+ logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9096
9164
 
9097
9165
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9098
9166
  if (!screenShareStream) {
@@ -9132,7 +9200,7 @@ class WebRTCPhone extends Emitter {
9132
9200
  return;
9133
9201
  }
9134
9202
 
9135
- logger$7.info('WebRTC phone - stop screen sharing', {
9203
+ logger$5.info('WebRTC phone - stop screen sharing', {
9136
9204
  restoreLocalStream,
9137
9205
  });
9138
9206
 
@@ -9188,24 +9256,26 @@ class WebRTCPhone extends Emitter {
9188
9256
  const pc = this.client.getPeerConnection(sipSessionId);
9189
9257
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9190
9258
 
9191
- logger$7.info('WebRTC phone - on screensharing', {
9259
+ logger$5.info('WebRTC phone - on screensharing', {
9192
9260
  hadVideo,
9193
9261
  id: this.getSipSessionId(sipSession),
9194
9262
  screenTrack,
9195
9263
  });
9196
9264
 
9197
- screenTrack.onended = () => {
9198
- logger$7.info('WebRTC phone - on screenshare ended', {
9199
- hadVideo,
9200
- id: this.getSipSessionId(sipSession),
9201
- screenTrack,
9202
- });
9265
+ if (screenTrack) {
9266
+ screenTrack.onended = () => {
9267
+ logger$5.info('WebRTC phone - on screenshare ended', {
9268
+ hadVideo,
9269
+ id: this.getSipSessionId(sipSession),
9270
+ screenTrack,
9271
+ });
9203
9272
 
9204
- this.eventEmitter.emit(
9205
- ON_SHARE_SCREEN_ENDING,
9206
- this._createCallSession(sipSession, callSession),
9207
- );
9208
- };
9273
+ this.eventEmitter.emit(
9274
+ ON_SHARE_SCREEN_ENDING,
9275
+ this._createCallSession(sipSession, callSession),
9276
+ );
9277
+ };
9278
+ }
9209
9279
 
9210
9280
  this.currentScreenShare = {
9211
9281
  stream: screenStream,
@@ -9225,7 +9295,7 @@ class WebRTCPhone extends Emitter {
9225
9295
  }
9226
9296
 
9227
9297
  _onCallAccepted(sipSession , cameraEnabled ) {
9228
- logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9298
+ logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9229
9299
 
9230
9300
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9231
9301
  this.currentSipSession = sipSession;
@@ -9243,7 +9313,7 @@ class WebRTCPhone extends Emitter {
9243
9313
  }
9244
9314
 
9245
9315
  changeAudioDevice(id ) {
9246
- logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9316
+ logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9247
9317
  this.audioOutputDeviceId = id;
9248
9318
  this.client.changeAudioOutputDevice(id);
9249
9319
  }
@@ -9253,14 +9323,14 @@ class WebRTCPhone extends Emitter {
9253
9323
  }
9254
9324
 
9255
9325
  changeRingDevice(id ) {
9256
- logger$7.info('WebRTC phone - changing ring device', { id });
9326
+ logger$5.info('WebRTC phone - changing ring device', { id });
9257
9327
 
9258
9328
  this.audioRingDeviceId = id;
9259
9329
  }
9260
9330
 
9261
9331
  // volume is a value between 0 and 1
9262
9332
  changeAudioVolume(volume ) {
9263
- logger$7.info('WebRTC phone - changing audio volume', { volume });
9333
+ logger$5.info('WebRTC phone - changing audio volume', { volume });
9264
9334
 
9265
9335
  this.audioOutputVolume = volume;
9266
9336
  this.client.changeAudioOutputVolume(volume);
@@ -9268,31 +9338,31 @@ class WebRTCPhone extends Emitter {
9268
9338
 
9269
9339
  // volume is a value between 0 and 1
9270
9340
  changeRingVolume(volume ) {
9271
- logger$7.info('WebRTC phone - changing ring volume', { volume });
9341
+ logger$5.info('WebRTC phone - changing ring volume', { volume });
9272
9342
 
9273
9343
  this.audioRingVolume = volume;
9274
9344
  }
9275
9345
 
9276
9346
  changeAudioInputDevice(id ) {
9277
- logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9347
+ logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9278
9348
 
9279
9349
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9280
9350
  }
9281
9351
 
9282
9352
  changeVideoInputDevice(id ) {
9283
- logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9353
+ logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9284
9354
 
9285
9355
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9286
9356
  }
9287
9357
 
9288
9358
  changeSessionVideoInputDevice(id ) {
9289
- logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9359
+ logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9290
9360
 
9291
9361
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9292
9362
  }
9293
9363
 
9294
9364
  _onCallTerminated(sipSession ) {
9295
- logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9365
+ logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9296
9366
 
9297
9367
  const callSession = this._createCallSession(sipSession);
9298
9368
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
@@ -9326,7 +9396,7 @@ class WebRTCPhone extends Emitter {
9326
9396
  const hasIncomingCallSession = this.hasIncomingCallSession();
9327
9397
 
9328
9398
  // Re-trigger incoming call event for remaining incoming calls
9329
- logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9399
+ logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9330
9400
  sipId: sipSession.id,
9331
9401
  shouldRetrigger,
9332
9402
  hasIncomingCallSession,
@@ -9417,37 +9487,37 @@ class WebRTCPhone extends Emitter {
9417
9487
 
9418
9488
  // Deprecated
9419
9489
  getLocalStreamForCall(callSession ) {
9420
- logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9490
+ logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9421
9491
 
9422
9492
  return this.getLocalStream(callSession);
9423
9493
  }
9424
9494
 
9425
9495
  // Deprecated
9426
9496
  getRemoteStreamForCall(callSession ) {
9427
- logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9497
+ logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9428
9498
 
9429
9499
  return this.getRemoteVideoStream(callSession);
9430
9500
  }
9431
9501
 
9432
9502
  getRemoteStreamsForCall(callSession ) {
9433
- logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9503
+ logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9434
9504
 
9435
9505
  return this.getRemoteStream(callSession);
9436
9506
  }
9437
9507
 
9438
9508
  accept(callSession , cameraEnabled ) {
9439
- logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9509
+ logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9440
9510
  if (this.currentSipSession) {
9441
9511
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9442
9512
  }
9443
9513
 
9444
9514
  if (!callSession) {
9445
- logger$7.warn('no CallSession to accept.');
9515
+ logger$5.warn('no CallSession to accept.');
9446
9516
  return Promise.resolve(null);
9447
9517
  }
9448
9518
 
9449
9519
  if (callSession.getId() in this.acceptedSessions) {
9450
- logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9520
+ logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9451
9521
  return Promise.resolve(callSession.sipCallId);
9452
9522
  }
9453
9523
 
@@ -9459,24 +9529,24 @@ class WebRTCPhone extends Emitter {
9459
9529
  const sipSession = this.client.getSipSession(callSession.getId());
9460
9530
  if (sipSession) {
9461
9531
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9462
- logger$7.warn('Trying to answer a terminated sipSession.');
9532
+ logger$5.warn('Trying to answer a terminated sipSession.');
9463
9533
 
9464
9534
  return Promise.resolve(null);
9465
9535
  }
9466
9536
 
9467
- logger$7.info('accept call, session found', { sipId: sipSession.id });
9537
+ logger$5.info('accept call, session found', { sipId: sipSession.id });
9468
9538
 
9469
9539
  // $FlowFixMe
9470
9540
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9471
9541
  return callSession.sipCallId;
9472
9542
  }).catch(e => {
9473
- logger$7.error(e);
9543
+ logger$5.error(e);
9474
9544
  this.endCurrentCall(callSession);
9475
9545
  throw e;
9476
9546
  });
9477
9547
  }
9478
9548
 
9479
- logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9549
+ logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9480
9550
 
9481
9551
  return Promise.resolve(null);
9482
9552
  }
@@ -9486,7 +9556,7 @@ class WebRTCPhone extends Emitter {
9486
9556
  }
9487
9557
 
9488
9558
  async reject(callSession ) {
9489
- logger$7.info('reject WebRTC called', { id: callSession.getId() });
9559
+ logger$5.info('reject WebRTC called', { id: callSession.getId() });
9490
9560
 
9491
9561
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9492
9562
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9498,14 +9568,14 @@ class WebRTCPhone extends Emitter {
9498
9568
 
9499
9569
  const sipSession = this.findSipSession(callSession);
9500
9570
  if (sipSession) {
9501
- logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
9571
+ logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9502
9572
 
9503
9573
  this.client.hangup(sipSession);
9504
9574
  }
9505
9575
  }
9506
9576
 
9507
9577
  async ignore(callSession ) {
9508
- logger$7.info('WebRTC ignore', { id: callSession.getId() });
9578
+ logger$5.info('WebRTC ignore', { id: callSession.getId() });
9509
9579
 
9510
9580
  // kill the ring
9511
9581
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9517,14 +9587,14 @@ class WebRTCPhone extends Emitter {
9517
9587
  const sipSession = this.findSipSession(callSession);
9518
9588
 
9519
9589
  if (sipSession) {
9520
- logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
9590
+ logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9521
9591
 
9522
9592
  return this.client.atxfer(sipSession);
9523
9593
  }
9524
9594
  }
9525
9595
 
9526
9596
  hold(callSession , withEvent = true, isConference = false) {
9527
- logger$7.info('WebRTC hold', { id: callSession.getId() });
9597
+ logger$5.info('WebRTC hold', { id: callSession.getId() });
9528
9598
 
9529
9599
  const sipSession = this.findSipSession(callSession);
9530
9600
 
@@ -9539,18 +9609,18 @@ class WebRTCPhone extends Emitter {
9539
9609
  }
9540
9610
 
9541
9611
  resume(callSession , isConference = false, withEvent = true) {
9542
- logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9612
+ logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9543
9613
 
9544
9614
  const sipSession = this.findSipSession(callSession);
9545
9615
  if (!sipSession) {
9546
9616
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9547
9617
  }
9548
9618
 
9549
- logger$7.info('WebRTC resuming', { sipId: sipSession.id });
9619
+ logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9550
9620
 
9551
9621
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9552
9622
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9553
- logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9623
+ logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9554
9624
  this.holdSipSession(this.currentSipSession, callSession);
9555
9625
  }
9556
9626
 
@@ -9575,7 +9645,7 @@ class WebRTCPhone extends Emitter {
9575
9645
  const sessionId = this.getSipSessionId(sipSession);
9576
9646
  const hasVideo = this.client.hasLocalVideo(sessionId);
9577
9647
 
9578
- logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9648
+ logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9579
9649
 
9580
9650
  // Stop screenshre if needed
9581
9651
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9606,7 +9676,7 @@ class WebRTCPhone extends Emitter {
9606
9676
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9607
9677
  }
9608
9678
  const sessionId = this.getSipSessionId(sipSession);
9609
- logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9679
+ logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
9610
9680
 
9611
9681
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9612
9682
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9650,14 +9720,14 @@ class WebRTCPhone extends Emitter {
9650
9720
  }
9651
9721
 
9652
9722
  mute(callSession , withEvent = true) {
9653
- logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9723
+ logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9654
9724
 
9655
9725
  const sipSession = this.findSipSession(callSession);
9656
9726
  if (!sipSession) {
9657
9727
  return;
9658
9728
  }
9659
9729
 
9660
- logger$7.info('WebRTC muting', { sipId: sipSession.id });
9730
+ logger$5.info('WebRTC muting', { sipId: sipSession.id });
9661
9731
  this.client.mute(sipSession);
9662
9732
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9663
9733
 
@@ -9671,14 +9741,14 @@ class WebRTCPhone extends Emitter {
9671
9741
  }
9672
9742
 
9673
9743
  unmute(callSession , withEvent = true) {
9674
- logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9744
+ logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9675
9745
 
9676
9746
  const sipSession = this.findSipSession(callSession);
9677
9747
  if (!sipSession) {
9678
9748
  return;
9679
9749
  }
9680
9750
 
9681
- logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9751
+ logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
9682
9752
  this.client.unmute(sipSession);
9683
9753
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9684
9754
 
@@ -9705,7 +9775,7 @@ class WebRTCPhone extends Emitter {
9705
9775
  if (!sipSession) {
9706
9776
  return;
9707
9777
  }
9708
- logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9778
+ logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
9709
9779
 
9710
9780
  this.client.toggleCameraOn(sipSession);
9711
9781
 
@@ -9717,7 +9787,7 @@ class WebRTCPhone extends Emitter {
9717
9787
  if (!sipSession) {
9718
9788
  return;
9719
9789
  }
9720
- logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9790
+ logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
9721
9791
 
9722
9792
  this.client.toggleCameraOff(sipSession);
9723
9793
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9729,7 +9799,7 @@ class WebRTCPhone extends Emitter {
9729
9799
  return;
9730
9800
  }
9731
9801
 
9732
- logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9802
+ logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
9733
9803
  this.client.sendDTMF(sipSession, tone);
9734
9804
  }
9735
9805
 
@@ -9737,7 +9807,7 @@ class WebRTCPhone extends Emitter {
9737
9807
  // @TODO: line is not used here
9738
9808
  async makeCall(number , line , cameraEnabled ,
9739
9809
  audioOnly = false, conference = false) {
9740
- logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9810
+ logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9741
9811
  if (!number) {
9742
9812
  return Promise.resolve(null);
9743
9813
  }
@@ -9747,7 +9817,7 @@ class WebRTCPhone extends Emitter {
9747
9817
  }
9748
9818
  if (this.currentSipSession) {
9749
9819
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9750
- logger$7.warn('Unable to hold current session when making another call', e);
9820
+ logger$5.warn('Unable to hold current session when making another call', e);
9751
9821
  });
9752
9822
  }
9753
9823
 
@@ -9757,7 +9827,7 @@ class WebRTCPhone extends Emitter {
9757
9827
  this._bindEvents(sipSession);
9758
9828
  } catch (error) {
9759
9829
  console.warn(error);
9760
- logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9830
+ logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9761
9831
  return Promise.resolve(null);
9762
9832
  }
9763
9833
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
@@ -9785,7 +9855,7 @@ class WebRTCPhone extends Emitter {
9785
9855
  return;
9786
9856
  }
9787
9857
 
9788
- logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9858
+ logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
9789
9859
 
9790
9860
  this.client.transfer(sipSession, target);
9791
9861
  }
@@ -9794,7 +9864,7 @@ class WebRTCPhone extends Emitter {
9794
9864
  const sipSession = this.client.getSipSession(source.sipCallId);
9795
9865
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9796
9866
 
9797
- logger$7.info('WebRTC indirect transfer', {
9867
+ logger$5.info('WebRTC indirect transfer', {
9798
9868
  sipId: sipSession ? sipSession.id : null,
9799
9869
  target: sipSessionTarget ? sipSessionTarget.id : null,
9800
9870
  });
@@ -9833,7 +9903,7 @@ class WebRTCPhone extends Emitter {
9833
9903
  return false;
9834
9904
  }
9835
9905
 
9836
- logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9906
+ logger$5.info('WebRTC hangup', { sipId: sipSession.id });
9837
9907
 
9838
9908
  const sipSessionId = this.getSipSessionId(sipSession);
9839
9909
 
@@ -9879,7 +9949,7 @@ class WebRTCPhone extends Emitter {
9879
9949
  endCurrentCall(callSession ) {
9880
9950
  const isCurrent = this.isCurrentCallSipSession(callSession);
9881
9951
 
9882
- logger$7.info('Ending current call', {
9952
+ logger$5.info('Ending current call', {
9883
9953
  id: callSession ? callSession.getId() : null,
9884
9954
  isCurrent,
9885
9955
  });
@@ -9903,7 +9973,7 @@ class WebRTCPhone extends Emitter {
9903
9973
  }
9904
9974
 
9905
9975
  async close() {
9906
- logger$7.info('WebRTC close');
9976
+ logger$5.info('WebRTC close');
9907
9977
 
9908
9978
  try {
9909
9979
  await Promise.race([
@@ -9911,7 +9981,7 @@ class WebRTCPhone extends Emitter {
9911
9981
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9912
9982
  ]);
9913
9983
  } catch (e) {
9914
- logger$7.error('WebRTC close, unregister error', e);
9984
+ logger$5.error('WebRTC close, unregister error', e);
9915
9985
  }
9916
9986
 
9917
9987
  this.client.close();
@@ -9929,12 +9999,12 @@ class WebRTCPhone extends Emitter {
9929
9999
  }
9930
10000
 
9931
10001
  enableRinging() {
9932
- logger$7.info('WebRTC enable ringing');
10002
+ logger$5.info('WebRTC enable ringing');
9933
10003
  this.ringingEnabled = true;
9934
10004
  }
9935
10005
 
9936
10006
  disableRinging() {
9937
- logger$7.info('WebRTC disable ringing');
10007
+ logger$5.info('WebRTC disable ringing');
9938
10008
  this.ringingEnabled = false;
9939
10009
  }
9940
10010
 
@@ -9974,7 +10044,7 @@ class WebRTCPhone extends Emitter {
9974
10044
 
9975
10045
  // Deprecated
9976
10046
  getLocalMediaStream(callSession ) {
9977
- logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10047
+ logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9978
10048
  return this.getLocalStream(callSession);
9979
10049
  }
9980
10050
 
@@ -9994,6 +10064,10 @@ class WebRTCPhone extends Emitter {
9994
10064
  return callSession ? this.client.getRemoteVideoStream(callSession.sipCallId) : null;
9995
10065
  }
9996
10066
 
10067
+ getRemoteVideoStreamFromPc(callSession ) {
10068
+ return callSession ? this.client.getRemoteVideoStreamFromPc(callSession.sipCallId) : null;
10069
+ }
10070
+
9997
10071
  hasRemoteVideo(callSession ) {
9998
10072
  return callSession ? this.client.hasRemoteVideo(callSession.sipCallId) : false;
9999
10073
  }
@@ -10012,7 +10086,7 @@ class WebRTCPhone extends Emitter {
10012
10086
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10013
10087
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10014
10088
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10015
- logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10089
+ logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10016
10090
 
10017
10091
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10018
10092
  this.incomingSessions.push(callSession.getId());
@@ -10035,7 +10109,7 @@ class WebRTCPhone extends Emitter {
10035
10109
  });
10036
10110
 
10037
10111
  this.client.on(this.client.ON_REINVITE, (...args) => {
10038
- logger$7.info('WebRTC on reinvite', {
10112
+ logger$5.info('WebRTC on reinvite', {
10039
10113
  sessionId: args[0].id,
10040
10114
  inviteId: args[1].id,
10041
10115
  updatedCalleeName: args[2],
@@ -10055,7 +10129,7 @@ class WebRTCPhone extends Emitter {
10055
10129
  });
10056
10130
 
10057
10131
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10058
- logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10132
+ logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10059
10133
 
10060
10134
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10061
10135
 
@@ -10066,22 +10140,22 @@ class WebRTCPhone extends Emitter {
10066
10140
  this.client.on('ended', () => {});
10067
10141
 
10068
10142
  this.client.on(this.client.ON_ERROR, e => {
10069
- logger$7.error('WebRTC error', e);
10143
+ logger$5.error('WebRTC error', e);
10070
10144
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10071
10145
  });
10072
10146
 
10073
10147
  this.client.on(this.client.UNREGISTERED, () => {
10074
- logger$7.info('WebRTC unregistered');
10148
+ logger$5.info('WebRTC unregistered');
10075
10149
  this.eventEmitter.emit(ON_UNREGISTERED);
10076
10150
  });
10077
10151
 
10078
10152
  this.client.on(this.client.ON_DISCONNECTED, () => {
10079
- logger$7.info('WebRTC disconnected');
10080
- this.eventEmitter.emit(ON_DISCONNECTED);
10153
+ logger$5.info('WebRTC disconnected');
10154
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
10081
10155
  });
10082
10156
 
10083
10157
  this.client.on(this.client.REGISTERED, () => {
10084
- logger$7.info('WebRTC registered', {
10158
+ logger$5.info('WebRTC registered', {
10085
10159
  shouldSendReinvite: this.shouldSendReinvite,
10086
10160
  state: this.currentSipSession ? this.currentSipSession.state : null,
10087
10161
  currentSipSession: !!this.currentSipSession,
@@ -10094,23 +10168,27 @@ class WebRTCPhone extends Emitter {
10094
10168
  if (this.shouldSendReinvite && this.currentSipSession
10095
10169
  && this.currentSipSession.state === sessionState.SessionState.Established) {
10096
10170
  this.shouldSendReinvite = false;
10171
+ const pc = this.currentSipSession.sessionDescriptionHandler.peerConnection;
10172
+ const isConference = pc ? pc.sfu : false;
10173
+ const hasVideo = this.currentCallSession && this.currentCallSession.cameraEnabled;
10174
+
10097
10175
  try {
10098
10176
  // Send reinvite with iceRestart
10099
- this.sendReinvite(this.currentCallSession, null, false, false, true);
10177
+ this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10100
10178
  } catch (e) {
10101
- logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10179
+ logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10102
10180
  }
10103
10181
  }
10104
10182
  });
10105
10183
 
10106
10184
  this.client.on(this.client.CONNECTED, () => {
10107
- logger$7.info('WebRTC client connected');
10185
+ logger$5.info('WebRTC client connected');
10108
10186
 
10109
10187
  this.stopHeartbeat();
10110
10188
  });
10111
10189
 
10112
10190
  this.client.on(this.client.DISCONNECTED, () => {
10113
- logger$7.info('WebRTC client disconnected');
10191
+ logger$5.info('WebRTC client disconnected');
10114
10192
 
10115
10193
  this.eventEmitter.emit(ON_UNREGISTERED);
10116
10194
 
@@ -10124,7 +10202,7 @@ class WebRTCPhone extends Emitter {
10124
10202
  });
10125
10203
 
10126
10204
  this.client.on(this.client.ON_TRACK, (session, event) => {
10127
- this.eventEmitter.emit(ON_TRACK, session, event);
10205
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
10128
10206
  });
10129
10207
 
10130
10208
  this.client.on('onVideoInputChange', stream => {
@@ -10139,7 +10217,7 @@ class WebRTCPhone extends Emitter {
10139
10217
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10140
10218
  const callSession = this.getCallSession(this.getSipSessionId(session));
10141
10219
 
10142
- this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10220
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10143
10221
  });
10144
10222
 
10145
10223
  // Used when upgrading directly in screenshare mode
@@ -10148,7 +10226,7 @@ class WebRTCPhone extends Emitter {
10148
10226
  const localStream = this.client.getLocalStream(sipSessionId);
10149
10227
  const callSession = this.callSessions[sipSessionId];
10150
10228
 
10151
- logger$7.info('Updrading directly in screensharing mode', {
10229
+ logger$5.info('Updrading directly in screensharing mode', {
10152
10230
  sipSessionId,
10153
10231
  tracks: localStream ? localStream.getTracks() : null,
10154
10232
  });
@@ -10180,6 +10258,15 @@ class WebRTCPhone extends Emitter {
10180
10258
  return this.client.getSipSessionId(sipSession);
10181
10259
  }
10182
10260
 
10261
+ _updateCallSession(callSession ) {
10262
+ const sipSession = this.findSipSession(callSession);
10263
+ const sipSessionId = sipSession ? this.getSipSessionId(sipSession) : null;
10264
+
10265
+ if (sipSessionId) {
10266
+ this.callSessions[sipSessionId] = callSession;
10267
+ }
10268
+ }
10269
+
10183
10270
  _onMessage(message ) {
10184
10271
  if (!message || message.method !== 'MESSAGE') {
10185
10272
  return;
@@ -10317,8 +10404,8 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10317
10404
  ON_CALL_ENDED: ON_CALL_ENDED,
10318
10405
  ON_CALL_ENDING: ON_CALL_ENDING,
10319
10406
  ON_MESSAGE: ON_MESSAGE,
10320
- ON_REINVITE: ON_REINVITE,
10321
- ON_TRACK: ON_TRACK,
10407
+ ON_REINVITE: ON_REINVITE$1,
10408
+ ON_TRACK: ON_TRACK$1,
10322
10409
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10323
10410
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10324
10411
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10333,13 +10420,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10333
10420
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10334
10421
  ON_CALL_ERROR: ON_CALL_ERROR,
10335
10422
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10336
- ON_NETWORK_STATS: ON_NETWORK_STATS,
10423
+ ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10337
10424
  ON_CHAT: ON_CHAT,
10338
10425
  ON_SIGNAL: ON_SIGNAL,
10339
- ON_DISCONNECTED: ON_DISCONNECTED,
10426
+ ON_DISCONNECTED: ON_DISCONNECTED$1,
10340
10427
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10341
10428
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10342
- events: events,
10429
+ events: events$1,
10343
10430
  'default': WebRTCPhone
10344
10431
  });
10345
10432
 
@@ -10677,6 +10764,11 @@ class Phone extends Emitter {
10677
10764
  return this.getRemoteVideoStream(callSession);
10678
10765
  }
10679
10766
 
10767
+ // Useful in a react-native environment when remoteMediaStream is not updated
10768
+ getRemoteVideoStreamFromPc(callSession ) {
10769
+ return this.phone ? this.phone.getRemoteVideoStreamFromPc(callSession) : false;
10770
+ }
10771
+
10680
10772
  hasVideo(callSession ) {
10681
10773
  return this.phone ? this.phone.hasVideo(callSession) : false;
10682
10774
  }
@@ -10728,7 +10820,7 @@ class Phone extends Emitter {
10728
10820
 
10729
10821
  _transferEvents() {
10730
10822
  this.unbind();
10731
- [...events$1, ...transportEvents].forEach(event => {
10823
+ [...events, ...transportEvents].forEach(event => {
10732
10824
  this.client.on(event, (...args) =>
10733
10825
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10734
10826
  });
@@ -10750,7 +10842,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10750
10842
 
10751
10843
  //
10752
10844
 
10753
- const SOCKET_EVENTS$1 = {
10845
+ const SOCKET_EVENTS = {
10754
10846
  ON_OPEN: 'onopen',
10755
10847
  ON_MESSAGE: 'onmessage',
10756
10848
  ON_ERROR: 'onerror',
@@ -10836,6 +10928,7 @@ const AGENT_PAUSED = 'agent_paused';
10836
10928
  const AGENT_UNPAUSED = 'agent_unpaused';
10837
10929
  const CONFERENCE_ADHOC_PARTICIPANT_LEFT = 'conference_adhoc_participant_left';
10838
10930
  const CONFERENCE_ADHOC_DELETED = 'conference_adhoc_deleted';
10931
+ const MEETING_USER_PROGRESS = 'meeting_user_progress';
10839
10932
 
10840
10933
  const BLACKLIST_EVENTS = [
10841
10934
  CHAT_MESSAGE_SENT,
@@ -10845,7 +10938,7 @@ const BLACKLIST_EVENTS = [
10845
10938
  ];
10846
10939
 
10847
10940
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10848
- const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10941
+ const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
10849
10942
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10850
10943
 
10851
10944
  class WebSocketClient extends Emitter {
@@ -10894,24 +10987,24 @@ class WebSocketClient extends Emitter {
10894
10987
  }
10895
10988
 
10896
10989
  connect() {
10897
- logger$5.info('connect method started', { host: this.host, token: this.token });
10990
+ logger$7.info('connect method started', { host: this.host, token: this.token });
10898
10991
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
10899
10992
  if (this.options.binaryType) {
10900
10993
  this.socket.binaryType = this.options.binaryType;
10901
10994
  }
10902
10995
 
10903
10996
  this.socket.onopen = () => {
10904
- logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
10905
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10997
+ logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
10998
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10906
10999
  };
10907
11000
 
10908
11001
  this.socket.onerror = event => {
10909
- logger$5.error('on Wazo WS error', event.target);
10910
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
11002
+ logger$7.error('on Wazo WS error', event.target);
11003
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10911
11004
  };
10912
11005
 
10913
11006
  this.socket.onmessage = (event ) => {
10914
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
11007
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10915
11008
 
10916
11009
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10917
11010
  let { name } = message;
@@ -10936,7 +11029,7 @@ class WebSocketClient extends Emitter {
10936
11029
 
10937
11030
  this.socket.onclose = event => {
10938
11031
  // Can't be converted to JSON (circular structure)
10939
- logger$5.info('on Wazo WS close', {
11032
+ logger$7.info('on Wazo WS close', {
10940
11033
  reason: event.reason,
10941
11034
  code: event.code,
10942
11035
  readyState: event.target.readyState,
@@ -10944,22 +11037,22 @@ class WebSocketClient extends Emitter {
10944
11037
  token: this.token,
10945
11038
  });
10946
11039
  this.initialized = false;
10947
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
11040
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10948
11041
 
10949
11042
  switch (event.code) {
10950
11043
  case 4002:
10951
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
11044
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10952
11045
  break;
10953
11046
  }
10954
11047
  };
10955
11048
 
10956
11049
  this.socket.onerror = event => {
10957
- logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11050
+ logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
10958
11051
  };
10959
11052
  }
10960
11053
 
10961
11054
  close(force = false) {
10962
- logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11055
+ logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
10963
11056
 
10964
11057
  if (!this.socket) {
10965
11058
  return;
@@ -10977,7 +11070,7 @@ class WebSocketClient extends Emitter {
10977
11070
 
10978
11071
  updateToken(token ) {
10979
11072
  this.token = token;
10980
- logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11073
+ logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
10981
11074
 
10982
11075
  if (this.socket) {
10983
11076
  // If still connected, send the token to the WS
@@ -10995,7 +11088,7 @@ class WebSocketClient extends Emitter {
10995
11088
  }
10996
11089
 
10997
11090
  startHeartbeat() {
10998
- logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11091
+ logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
10999
11092
 
11000
11093
  if (!this.socket) {
11001
11094
  this.heartbeat.stop();
@@ -11009,7 +11102,7 @@ class WebSocketClient extends Emitter {
11009
11102
  }
11010
11103
 
11011
11104
  stopHeartbeat() {
11012
- logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11105
+ logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11013
11106
 
11014
11107
  this.heartbeat.stop();
11015
11108
  }
@@ -11039,7 +11132,7 @@ class WebSocketClient extends Emitter {
11039
11132
  }
11040
11133
 
11041
11134
  reconnect(reason ) {
11042
- logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11135
+ logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11043
11136
  if (!this.socket) {
11044
11137
  return;
11045
11138
  }
@@ -11064,7 +11157,7 @@ class WebSocketClient extends Emitter {
11064
11157
  break;
11065
11158
  case 'start':
11066
11159
  this.initialized = true;
11067
- this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
11160
+ this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
11068
11161
  break;
11069
11162
  default:
11070
11163
  this.eventEmitter.emit('message', message);
@@ -11095,7 +11188,7 @@ class WebSocketClient extends Emitter {
11095
11188
  this.close();
11096
11189
  }
11097
11190
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11098
- logger$5.log('Wazo WS url computed to reconnect', { url });
11191
+ logger$7.log('Wazo WS url computed to reconnect', { url });
11099
11192
 
11100
11193
  return url;
11101
11194
  }
@@ -11103,15 +11196,15 @@ class WebSocketClient extends Emitter {
11103
11196
  _onHeartbeat(message ) {
11104
11197
  if (message.payload === 'pong') {
11105
11198
  this.heartbeat.onHeartbeat();
11106
- logger$5.log('on heartbeat received from Wazo WS');
11199
+ logger$7.log('on heartbeat received from Wazo WS');
11107
11200
  }
11108
11201
  }
11109
11202
 
11110
11203
  async _onHeartbeatTimeout() {
11111
- logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
11204
+ logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
11112
11205
 
11113
11206
  this.close();
11114
- this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
11207
+ this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
11115
11208
 
11116
11209
  if (this.onHeartBeatTimeout) {
11117
11210
  this.onHeartBeatTimeout();
@@ -11186,11 +11279,12 @@ WebSocketClient.eventLists = [
11186
11279
  AGENT_UNPAUSED,
11187
11280
  CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11188
11281
  CONFERENCE_ADHOC_DELETED,
11282
+ MEETING_USER_PROGRESS,
11189
11283
  ];
11190
11284
 
11191
11285
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11192
11286
  __proto__: null,
11193
- SOCKET_EVENTS: SOCKET_EVENTS$1,
11287
+ SOCKET_EVENTS: SOCKET_EVENTS,
11194
11288
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11195
11289
  FAVORITE_ADDED: FAVORITE_ADDED,
11196
11290
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11256,16 +11350,17 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11256
11350
  AGENT_UNPAUSED: AGENT_UNPAUSED,
11257
11351
  CONFERENCE_ADHOC_PARTICIPANT_LEFT: CONFERENCE_ADHOC_PARTICIPANT_LEFT,
11258
11352
  CONFERENCE_ADHOC_DELETED: CONFERENCE_ADHOC_DELETED,
11353
+ MEETING_USER_PROGRESS: MEETING_USER_PROGRESS,
11259
11354
  HEARTBEAT_ENGINE_VERSION: HEARTBEAT_ENGINE_VERSION,
11260
11355
  'default': WebSocketClient
11261
11356
  });
11262
11357
 
11263
11358
  //
11264
11359
 
11265
- const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11266
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11360
+ const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11361
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11267
11362
 
11268
- const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
11363
+ const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
11269
11364
 
11270
11365
  class Websocket extends Emitter {
11271
11366
 
@@ -11279,9 +11374,9 @@ class Websocket extends Emitter {
11279
11374
  // $FlowFixMe
11280
11375
  this[key] = OTHER_EVENTS[key];
11281
11376
  });
11282
- Object.keys(SOCKET_EVENTS).forEach(key => {
11377
+ Object.keys(SOCKET_EVENTS$1).forEach(key => {
11283
11378
  // $FlowFixMe
11284
- this[key] = SOCKET_EVENTS[key];
11379
+ this[key] = SOCKET_EVENTS$1[key];
11285
11380
  });
11286
11381
  this.eventLists = WebSocketClient.eventLists;
11287
11382
 
@@ -11289,7 +11384,7 @@ class Websocket extends Emitter {
11289
11384
  }
11290
11385
 
11291
11386
  open(host , session ) {
11292
- logger$4.info('open simple WebSocket', { host, token: session.token });
11387
+ logger$8.info('open simple WebSocket', { host, token: session.token });
11293
11388
  this.ws = new WebSocketClient(
11294
11389
  {
11295
11390
  host,
@@ -11317,7 +11412,7 @@ class Websocket extends Emitter {
11317
11412
  }
11318
11413
 
11319
11414
  updateToken(token ) {
11320
- logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
11415
+ logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
11321
11416
 
11322
11417
  if (!this.ws) {
11323
11418
  return;
@@ -11345,7 +11440,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11345
11440
 
11346
11441
  //
11347
11442
 
11348
- const logger$3 = IssueReporter$1.loggerFor('room');
11443
+ const logger$9 = IssueReporter$1.loggerFor('room');
11349
11444
 
11350
11445
  class Participant extends Emitter {
11351
11446
 
@@ -11467,7 +11562,7 @@ class Participant extends Emitter {
11467
11562
  }
11468
11563
 
11469
11564
  onTalking(isTalking ) {
11470
- logger$3.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11565
+ logger$9.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11471
11566
  this.isTalking = isTalking;
11472
11567
  // you may notice we're not broadcasting: since all participants are getting this info
11473
11568
  // directly from asterisk, there's no need to do so
@@ -11570,7 +11665,7 @@ class Participant extends Emitter {
11570
11665
  }
11571
11666
 
11572
11667
  updateStatus(status , broadcast = true) {
11573
- logger$3.info('updating participant status', { name: this.name, status });
11668
+ logger$9.info('updating participant status', { name: this.name, status });
11574
11669
 
11575
11670
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11576
11671
  if (status.audioMuted) {
@@ -11618,7 +11713,7 @@ class Participant extends Emitter {
11618
11713
 
11619
11714
  broadcastStatus(inboundStatus = null) {
11620
11715
  const status = inboundStatus || this.getStatus();
11621
- logger$3.info('broadcasting participant status', { callId: this.callId, status });
11716
+ logger$9.info('broadcasting participant status', { callId: this.callId, status });
11622
11717
 
11623
11718
  this.room.sendSignal({
11624
11719
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11654,9 +11749,9 @@ class LocalParticipant extends Participant {
11654
11749
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11655
11750
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11656
11751
 
11657
- const logger$2 = IssueReporter$1.loggerFor('sdk-room');
11752
+ const logger$a = IssueReporter$1.loggerFor('sdk-room');
11658
11753
 
11659
- class Room$1 extends Emitter {
11754
+ class Room extends Emitter {
11660
11755
 
11661
11756
 
11662
11757
 
@@ -11714,7 +11809,7 @@ class Room$1 extends Emitter {
11714
11809
  extra = {},
11715
11810
  ) {
11716
11811
  super();
11717
- logger$2.info('room initialized', { callId, extension, sourceId, meetingUuid });
11812
+ logger$a.info('room initialized', { callId, extension, sourceId, meetingUuid });
11718
11813
 
11719
11814
  // Represents the room callSession
11720
11815
  this.callSession = callSession;
@@ -11780,7 +11875,7 @@ class Room$1 extends Emitter {
11780
11875
  * @returns {Promise<Room>}
11781
11876
  */
11782
11877
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11783
- logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
11878
+ logger$a.info('connecting to room', { extension, audioOnly, room: !!room });
11784
11879
 
11785
11880
  if (!room) {
11786
11881
  await Wazo.Phone.connect();
@@ -11793,7 +11888,7 @@ class Room$1 extends Emitter {
11793
11888
 
11794
11889
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11795
11890
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11796
- logger$2.info('room call received via WS', { callId: data.call_id });
11891
+ logger$a.info('room call received via WS', { callId: data.call_id });
11797
11892
  if (room) {
11798
11893
  room.setCallId(data.call_id);
11799
11894
  }
@@ -11801,7 +11896,7 @@ class Room$1 extends Emitter {
11801
11896
 
11802
11897
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11803
11898
  // eslint-disable-next-line no-param-reassign
11804
- room = new Room$1(callSession, extension, null, null, extra);
11899
+ room = new Room(callSession, extension, null, null, extra);
11805
11900
 
11806
11901
  // Wait for the call to be accepted
11807
11902
  await new Promise((resolve, reject) => {
@@ -11822,7 +11917,7 @@ class Room$1 extends Emitter {
11822
11917
  // Retrieve conference
11823
11918
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11824
11919
 
11825
- logger$2.info('connected to room', {
11920
+ logger$a.info('connected to room', {
11826
11921
  sourceId: conference ? conference.sourceId : null,
11827
11922
  name: conference ? conference.name : null,
11828
11923
  });
@@ -11832,7 +11927,7 @@ class Room$1 extends Emitter {
11832
11927
  room.setName(conference.name);
11833
11928
  }
11834
11929
  } else if (meeting) {
11835
- logger$2.info('Already connected to meeting', {
11930
+ logger$a.info('Already connected to meeting', {
11836
11931
  uuid: meeting.uuid,
11837
11932
  name: meeting.name,
11838
11933
  });
@@ -11845,13 +11940,13 @@ class Room$1 extends Emitter {
11845
11940
  }
11846
11941
 
11847
11942
  static disconnect() {
11848
- logger$2.info('static disconnection to room');
11943
+ logger$a.info('static disconnection to room');
11849
11944
 
11850
11945
  Wazo.Phone.disconnect();
11851
11946
  }
11852
11947
 
11853
11948
  async disconnect() {
11854
- logger$2.info('disconnection to room called');
11949
+ logger$a.info('disconnection to room called');
11855
11950
 
11856
11951
  await Wazo.Phone.hangup(this.callSession);
11857
11952
  this.callSession = null;
@@ -11871,19 +11966,19 @@ class Room$1 extends Emitter {
11871
11966
  }
11872
11967
 
11873
11968
  setSourceId(sourceId ) {
11874
- logger$2.info('set room source id', { sourceId });
11969
+ logger$a.info('set room source id', { sourceId });
11875
11970
 
11876
11971
  this.sourceId = sourceId;
11877
11972
  }
11878
11973
 
11879
11974
  setMeetingUuid(meetingUuid ) {
11880
- logger$2.info('set meeting uuid', { meetingUuid });
11975
+ logger$a.info('set meeting uuid', { meetingUuid });
11881
11976
 
11882
11977
  this.meetingUuid = meetingUuid;
11883
11978
  }
11884
11979
 
11885
11980
  setCallId(callId ) {
11886
- logger$2.info('set room call id', { callId });
11981
+ logger$a.info('set room call id', { callId });
11887
11982
 
11888
11983
  if (callId) {
11889
11984
  this.callId = callId;
@@ -11891,7 +11986,7 @@ class Room$1 extends Emitter {
11891
11986
  }
11892
11987
 
11893
11988
  setName(name ) {
11894
- logger$2.info('set room name', { name });
11989
+ logger$a.info('set room name', { name });
11895
11990
 
11896
11991
  this.name = name;
11897
11992
  }
@@ -11910,7 +12005,7 @@ class Room$1 extends Emitter {
11910
12005
  }
11911
12006
 
11912
12007
  async startScreenSharing(constraints ) {
11913
- logger$2.info('start room screen sharing', { constraints });
12008
+ logger$a.info('start room screen sharing', { constraints });
11914
12009
 
11915
12010
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11916
12011
  if (!screensharingStream) {
@@ -11924,7 +12019,7 @@ class Room$1 extends Emitter {
11924
12019
  }
11925
12020
 
11926
12021
  async stopScreenSharing(restoreLocalStream = true) {
11927
- logger$2.info('stop room screen sharing');
12022
+ logger$a.info('stop room screen sharing');
11928
12023
 
11929
12024
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11930
12025
 
@@ -11936,7 +12031,7 @@ class Room$1 extends Emitter {
11936
12031
  }
11937
12032
 
11938
12033
  turnCameraOff() {
11939
- logger$2.info('turn room camera off');
12034
+ logger$a.info('turn room camera off');
11940
12035
 
11941
12036
  Wazo.Phone.turnCameraOff(this.callSession);
11942
12037
 
@@ -11946,7 +12041,7 @@ class Room$1 extends Emitter {
11946
12041
  }
11947
12042
 
11948
12043
  turnCameraOn() {
11949
- logger$2.info('turn room camera on');
12044
+ logger$a.info('turn room camera on');
11950
12045
 
11951
12046
  Wazo.Phone.turnCameraOn(this.callSession);
11952
12047
 
@@ -11956,7 +12051,7 @@ class Room$1 extends Emitter {
11956
12051
  }
11957
12052
 
11958
12053
  mute() {
11959
- logger$2.info('mute room');
12054
+ logger$a.info('mute room');
11960
12055
 
11961
12056
  Wazo.Phone.mute(this.callSession);
11962
12057
 
@@ -11964,7 +12059,7 @@ class Room$1 extends Emitter {
11964
12059
  }
11965
12060
 
11966
12061
  unmute() {
11967
- logger$2.info('unmute room');
12062
+ logger$a.info('unmute room');
11968
12063
 
11969
12064
  Wazo.Phone.unmute(this.callSession);
11970
12065
 
@@ -11984,7 +12079,7 @@ class Room$1 extends Emitter {
11984
12079
  }
11985
12080
 
11986
12081
  hold() {
11987
- logger$2.info('hold room');
12082
+ logger$a.info('hold room');
11988
12083
 
11989
12084
  Wazo.Phone.hold(this.callSession, true);
11990
12085
 
@@ -11994,7 +12089,7 @@ class Room$1 extends Emitter {
11994
12089
  }
11995
12090
 
11996
12091
  async resume() {
11997
- logger$2.info('resume room');
12092
+ logger$a.info('resume room');
11998
12093
 
11999
12094
  const newStream = await Wazo.Phone.resume(this.callSession, true);
12000
12095
 
@@ -12022,13 +12117,13 @@ class Room$1 extends Emitter {
12022
12117
  }
12023
12118
 
12024
12119
  sendDTMF(tone ) {
12025
- logger$2.info('send room DTMF', { tone });
12120
+ logger$a.info('send room DTMF', { tone });
12026
12121
 
12027
12122
  Wazo.Phone.sendDTMF(tone, this.callSession);
12028
12123
  }
12029
12124
 
12030
12125
  async sendReinvite(newConstraints = null) {
12031
- logger$2.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
12126
+ logger$a.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
12032
12127
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
12033
12128
 
12034
12129
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -12087,7 +12182,7 @@ class Room$1 extends Emitter {
12087
12182
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
12088
12183
 
12089
12184
  this.on(this.ON_AUDIO_STREAM, stream => {
12090
- logger$2.info('on room audio stream');
12185
+ logger$a.info('on room audio stream');
12091
12186
 
12092
12187
  this.audioStream = stream;
12093
12188
  if (!this.roomAudioElement) {
@@ -12100,7 +12195,7 @@ class Room$1 extends Emitter {
12100
12195
  });
12101
12196
 
12102
12197
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
12103
- logger$2.info('on room video stream', { streamId });
12198
+ logger$a.info('on room video stream', { streamId });
12104
12199
 
12105
12200
  this._mapMsid(sipSession.body.body);
12106
12201
 
@@ -12115,7 +12210,7 @@ class Room$1 extends Emitter {
12115
12210
  });
12116
12211
 
12117
12212
  this.on(this.ON_REMOVE_STREAM, stream => {
12118
- logger$2.info('on room remove stream');
12213
+ logger$a.info('on room remove stream');
12119
12214
 
12120
12215
  const participant = this.participants.find(someParticipant =>
12121
12216
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -12247,7 +12342,7 @@ class Room$1 extends Emitter {
12247
12342
  const requester = this._getParticipantFromCallId(origin.callId);
12248
12343
  if (requester) {
12249
12344
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
12250
- logger$2.info('trigger room requester status', { origin });
12345
+ logger$a.info('trigger room requester status', { origin });
12251
12346
  requester.triggerUpdate('REQUESTER_UPDATE');
12252
12347
  }
12253
12348
  break;
@@ -12278,24 +12373,24 @@ class Room$1 extends Emitter {
12278
12373
 
12279
12374
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
12280
12375
  if (participant.user_uuid === session.uuid) {
12281
- logger$2.info('room current user joined');
12376
+ logger$a.info('room current user joined');
12282
12377
 
12283
12378
  // Retrieve participants via an API calls
12284
12379
  const conferenceId = this.sourceId || payload.data.conference_id;
12285
12380
  let response;
12286
12381
  try {
12287
12382
  if (this.meetingUuid) {
12288
- logger$2.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12383
+ logger$a.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12289
12384
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
12290
12385
  } else {
12291
- logger$2.info('fetching conference participants', { conferenceId });
12386
+ logger$a.info('fetching conference participants', { conferenceId });
12292
12387
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
12293
12388
  }
12294
12389
  } catch (e) {
12295
- logger$2.error('room participants fetching, error', e);
12390
+ logger$a.error('room participants fetching, error', e);
12296
12391
  }
12297
12392
  if (response) {
12298
- logger$2.info('conference participants fetched', { nb: response.items.length });
12393
+ logger$a.info('conference participants fetched', { nb: response.items.length });
12299
12394
  participants = response.items.map(item => {
12300
12395
  const isMe = item.call_id === this.callId;
12301
12396
 
@@ -12322,7 +12417,7 @@ class Room$1 extends Emitter {
12322
12417
  ? new Wazo.RemoteParticipant(this, participant)
12323
12418
  : null;
12324
12419
 
12325
- logger$2.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12420
+ logger$a.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12326
12421
 
12327
12422
  if (remoteParticipant) {
12328
12423
  this.participants.push(remoteParticipant);
@@ -12487,12 +12582,12 @@ class Room$1 extends Emitter {
12487
12582
 
12488
12583
  //
12489
12584
 
12490
- const logger$1 = IssueReporter$1.loggerFor('sdk-sip-room');
12585
+ const logger$b = IssueReporter$1.loggerFor('sdk-sip-room');
12491
12586
 
12492
- class SipRoom extends Room$1 {
12587
+ class SipRoom extends Room {
12493
12588
 
12494
12589
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12495
- logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
12590
+ logger$b.info('connecting to sip room', { extension, audioOnly, room: !!room });
12496
12591
 
12497
12592
  if (!room) {
12498
12593
  await Wazo.Phone.connect();
@@ -12508,7 +12603,7 @@ class SipRoom extends Room$1 {
12508
12603
  room.setCallId(room.callSession.call.id);
12509
12604
  }
12510
12605
 
12511
- logger$1.info('connected to room', {
12606
+ logger$b.info('connected to room', {
12512
12607
  extension: room.extension,
12513
12608
  });
12514
12609
 
@@ -12516,7 +12611,7 @@ class SipRoom extends Room$1 {
12516
12611
  }
12517
12612
 
12518
12613
  mute() {
12519
- logger$1.info('mute sip room');
12614
+ logger$b.info('mute sip room');
12520
12615
 
12521
12616
  Wazo.Phone.mute(this.callSession, false);
12522
12617
 
@@ -12524,7 +12619,7 @@ class SipRoom extends Room$1 {
12524
12619
  }
12525
12620
 
12526
12621
  unmute() {
12527
- logger$1.info('unmute sip room');
12622
+ logger$b.info('unmute sip room');
12528
12623
 
12529
12624
  Wazo.Phone.unmute(this.callSession, false);
12530
12625
 
@@ -12792,7 +12887,7 @@ class NotificationOptions {
12792
12887
 
12793
12888
 
12794
12889
  // Represents a conference room, like `9000`.
12795
- class Room {
12890
+ class Room$1 {
12796
12891
 
12797
12892
 
12798
12893
 
@@ -12813,7 +12908,7 @@ class Room {
12813
12908
  }
12814
12909
 
12815
12910
  connect(callSession ) {
12816
- return new Room({ ...this, connectedCallSession: callSession });
12911
+ return new Room$1({ ...this, connectedCallSession: callSession });
12817
12912
  }
12818
12913
 
12819
12914
  has(callSession ) {
@@ -12822,7 +12917,7 @@ class Room {
12822
12917
 
12823
12918
  addParticipant(uuid , extension , talking = null) {
12824
12919
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12825
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12920
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12826
12921
  }
12827
12922
 
12828
12923
  return this;
@@ -12841,7 +12936,7 @@ class Room {
12841
12936
  updatedParticipants.push(participant);
12842
12937
  }
12843
12938
 
12844
- return new Room({ ...this, participants: updatedParticipants });
12939
+ return new Room$1({ ...this, participants: updatedParticipants });
12845
12940
  }
12846
12941
 
12847
12942
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12857,7 +12952,7 @@ class Room {
12857
12952
  updatedParticipants.push(participant);
12858
12953
  }
12859
12954
 
12860
- return new Room({ ...this, participants: updatedParticipants });
12955
+ return new Room$1({ ...this, participants: updatedParticipants });
12861
12956
  }
12862
12957
 
12863
12958
  hasCallWithId(id ) {
@@ -12865,18 +12960,18 @@ class Room {
12865
12960
  }
12866
12961
 
12867
12962
  disconnect() {
12868
- return new Room({ ...this, connectedCallSession: null });
12963
+ return new Room$1({ ...this, connectedCallSession: null });
12869
12964
  }
12870
12965
 
12871
12966
  removeParticipantWithUUID(uuid ) {
12872
- return new Room({
12967
+ return new Room$1({
12873
12968
  ...this,
12874
12969
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12875
12970
  });
12876
12971
  }
12877
12972
 
12878
12973
  removeParticipantWithExtension(extension ) {
12879
- return new Room({
12974
+ return new Room$1({
12880
12975
  ...this,
12881
12976
  participants: this.participants.filter(participant => participant.extension !== extension),
12882
12977
  });
@@ -12887,7 +12982,7 @@ class Room {
12887
12982
  }
12888
12983
 
12889
12984
  static newFrom(room ) {
12890
- return newFrom(room, Room);
12985
+ return newFrom(room, Room$1);
12891
12986
  }
12892
12987
  }
12893
12988
 
@@ -13194,11 +13289,11 @@ var wazoWebsocket = {
13194
13289
  resolve();
13195
13290
  };
13196
13291
 
13197
- client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
13292
+ client.on(SOCKET_EVENTS.ON_ERROR, error => {
13198
13293
  handleError(`Connection error : ${error}`);
13199
13294
  });
13200
13295
 
13201
- client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
13296
+ client.on(SOCKET_EVENTS.ON_OPEN, () => {
13202
13297
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
13203
13298
  client.setOnHeartbeatTimeout(() => {
13204
13299
  handleError('No response to heartbeat');
@@ -13299,7 +13394,7 @@ var webrtc = {
13299
13394
  }),
13300
13395
  };
13301
13396
 
13302
- const parseCandidate = line => {
13397
+ const parseCandidate$1 = line => {
13303
13398
  let parts;
13304
13399
  // Parse both variants.
13305
13400
  if (line.indexOf('a=candidate:') === 0) {
@@ -13390,7 +13485,7 @@ var SymmetricNat = {
13390
13485
  }
13391
13486
 
13392
13487
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13393
- const cand = parseCandidate(e.candidate.candidate);
13488
+ const cand = parseCandidate$1(e.candidate.candidate);
13394
13489
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13395
13490
  candidates[cand.relatedPort].push(cand.port);
13396
13491
  } else if (!e.candidate) {
@@ -13458,7 +13553,7 @@ var iceIpv4 = {
13458
13553
  const rawCandidate = e.candidate.candidate;
13459
13554
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13460
13555
  hasSrflxOrRelay = true;
13461
- const candidate = parseCandidate(e.candidate.candidate);
13556
+ const candidate = parseCandidate$1(e.candidate.candidate);
13462
13557
  ips.push(candidate.ip);
13463
13558
  }
13464
13559
  } else if (!e.candidate) {
@@ -13495,7 +13590,7 @@ var checks = [
13495
13590
 
13496
13591
  //
13497
13592
 
13498
- const logger = IssueReporter$1.loggerFor('engine-check');
13593
+ const logger$c = IssueReporter$1.loggerFor('engine-check');
13499
13594
 
13500
13595
  class Checker {
13501
13596
 
@@ -13513,28 +13608,28 @@ class Checker {
13513
13608
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13514
13609
  await this._addEngineVersion();
13515
13610
 
13516
- logger.info('Engine check starting');
13611
+ logger$c.info('Engine check starting');
13517
13612
 
13518
13613
  for (let i = 0; i < this.checks.length; i++) {
13519
13614
  const { name, check } = this.checks[i];
13520
13615
 
13521
- logger.info(`Checking ${name} ...`);
13616
+ logger$c.info(`Checking ${name} ...`);
13522
13617
 
13523
13618
  onCheckBegin(name);
13524
13619
  try {
13525
13620
  // eslint-disable-next-line no-await-in-loop
13526
13621
  const result = await check(this.server, this.session, this.externalAppConfig);
13527
- logger.info(`Checking ${name} success.`, { result });
13622
+ logger$c.info(`Checking ${name} success.`, { result });
13528
13623
 
13529
13624
  onCheckResult(name, result);
13530
13625
  } catch (e) {
13531
- logger.info(`Checking ${name} failure`, { message: e.message });
13626
+ logger$c.info(`Checking ${name} failure`, { message: e.message });
13532
13627
 
13533
13628
  onCheckResult(name, e);
13534
13629
  }
13535
13630
  }
13536
13631
 
13537
- logger.info('Engine check done.');
13632
+ logger$c.info('Engine check done.');
13538
13633
  }
13539
13634
 
13540
13635
  addCheck(check ) {
@@ -13558,7 +13653,7 @@ const Wazo = {
13558
13653
  Auth: Auth$1,
13559
13654
  Phone: Phone$1,
13560
13655
  Websocket: Websocket$1,
13561
- Room: Room$1,
13656
+ Room,
13562
13657
  SipRoom,
13563
13658
  RemoteParticipant,
13564
13659
  LocalParticipant,
@@ -13591,7 +13686,7 @@ const Wazo = {
13591
13686
  Session,
13592
13687
  Voicemail,
13593
13688
  Relocation,
13594
- ConferenceRoom: Room,
13689
+ ConferenceRoom: Room$1,
13595
13690
  CallSession,
13596
13691
  IndirectTransfer,
13597
13692
  SwitchboardCall,