@wazo/sdk 0.37.24 → 0.37.28

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 (129) hide show
  1. package/README.md +96 -58
  2. package/dist/wazo-sdk.js +6 -6
  3. package/esm/__tests__/api-client.test.js +14 -14
  4. package/esm/__tests__/web-rtc-client.test.js +130 -108
  5. package/esm/api/agentd.js +1 -1
  6. package/esm/api/amid.js +2 -2
  7. package/esm/api/application.js +1 -1
  8. package/esm/api/auth.js +1 -1
  9. package/esm/api/call-logd.js +3 -3
  10. package/esm/api/calld.js +1 -1
  11. package/esm/api/chatd.js +1 -1
  12. package/esm/api/confd.js +1 -1
  13. package/esm/api/ctid-ng.js +4 -4
  14. package/esm/api/dird.js +3 -3
  15. package/esm/api/webhookd.js +2 -2
  16. package/esm/api-client.js +14 -14
  17. package/esm/checker/Checker.js +155 -133
  18. package/esm/checker/checks/aor.js +14 -14
  19. package/esm/checker/checks/api.js +14 -14
  20. package/esm/checker/checks/index.js +145 -123
  21. package/esm/checker/checks/wazo-websocket.js +16 -16
  22. package/esm/checker/checks/webrtc-transport.js +130 -108
  23. package/esm/checker/checks/webrtc.js +130 -108
  24. package/esm/domain/AdHocAPIConference.js +14 -14
  25. package/esm/domain/CallLog.js +1 -1
  26. package/esm/domain/CallSession.js +15 -0
  27. package/esm/domain/Contact.js +2 -2
  28. package/esm/domain/Features.js +14 -14
  29. package/esm/domain/Phone/CTIPhone.js +43 -28
  30. package/esm/domain/Phone/WebRTCPhone.js +126 -90
  31. package/esm/domain/SFUNotAvailableError.js +9 -0
  32. package/esm/domain/__tests__/CallLog.test.js +1 -1
  33. package/esm/domain/__tests__/CallSession.test.js +15 -0
  34. package/esm/domain/__tests__/Contact.test.js +2 -2
  35. package/esm/domain/__tests__/IndirectTransfer.test.js +15 -0
  36. package/esm/domain/__tests__/Room.test.js +15 -0
  37. package/esm/index.js +415 -346
  38. package/esm/lib/WazoSessionDescriptionHandler.js +10 -5
  39. package/esm/service/CallApi.js +14 -14
  40. package/esm/service/IssueReporter.js +2 -2
  41. package/esm/service/__tests__/IssueReporter.test.js +2 -2
  42. package/esm/service/getApiClient.js +14 -14
  43. package/esm/simple/Auth.js +404 -336
  44. package/esm/simple/Configuration.js +404 -336
  45. package/esm/simple/Directory.js +14 -14
  46. package/esm/simple/Phone.js +404 -336
  47. package/esm/simple/Websocket.js +18 -18
  48. package/esm/simple/index.js +408 -340
  49. package/esm/simple/room/LocalParticipant.js +408 -340
  50. package/esm/simple/room/Participant.js +408 -340
  51. package/esm/simple/room/RemoteParticipant.js +408 -340
  52. package/esm/simple/room/Room.js +409 -341
  53. package/esm/simple/room/SipRoom.js +408 -340
  54. package/esm/simple/room/Stream.js +408 -340
  55. package/esm/simple/room/__tests__/RemoteParticipant.test.js +408 -340
  56. package/esm/simple/utils.js +408 -340
  57. package/esm/utils/__tests__/api-requester.test.js +1 -1
  58. package/esm/utils/api-requester.js +1 -1
  59. package/esm/web-rtc-client.js +130 -108
  60. package/esm/websocket-client.js +16 -16
  61. package/lib/__tests__/api-client.test.js +14 -14
  62. package/lib/__tests__/web-rtc-client.test.js +130 -108
  63. package/lib/api/agentd.js +1 -1
  64. package/lib/api/amid.js +2 -2
  65. package/lib/api/application.js +1 -1
  66. package/lib/api/auth.js +1 -1
  67. package/lib/api/call-logd.js +3 -3
  68. package/lib/api/calld.js +1 -1
  69. package/lib/api/chatd.js +1 -1
  70. package/lib/api/confd.js +1 -1
  71. package/lib/api/ctid-ng.js +4 -4
  72. package/lib/api/dird.js +3 -3
  73. package/lib/api/webhookd.js +2 -2
  74. package/lib/api-client.js +14 -14
  75. package/lib/checker/Checker.js +155 -133
  76. package/lib/checker/checks/aor.js +14 -14
  77. package/lib/checker/checks/api.js +14 -14
  78. package/lib/checker/checks/index.js +145 -123
  79. package/lib/checker/checks/wazo-websocket.js +16 -16
  80. package/lib/checker/checks/webrtc-transport.js +130 -108
  81. package/lib/checker/checks/webrtc.js +130 -108
  82. package/lib/domain/AdHocAPIConference.js +14 -14
  83. package/lib/domain/CallLog.js +1 -1
  84. package/lib/domain/CallSession.js +15 -0
  85. package/lib/domain/Contact.js +2 -2
  86. package/lib/domain/Features.js +14 -14
  87. package/lib/domain/Phone/CTIPhone.js +43 -28
  88. package/lib/domain/Phone/WebRTCPhone.js +126 -89
  89. package/lib/domain/SFUNotAvailableError.js +11 -0
  90. package/lib/domain/__tests__/CallLog.test.js +1 -1
  91. package/lib/domain/__tests__/CallSession.test.js +15 -0
  92. package/lib/domain/__tests__/Contact.test.js +2 -2
  93. package/lib/domain/__tests__/IndirectTransfer.test.js +15 -0
  94. package/lib/domain/__tests__/Room.test.js +15 -0
  95. package/lib/index.js +415 -346
  96. package/lib/lib/WazoSessionDescriptionHandler.js +10 -5
  97. package/lib/service/CallApi.js +14 -14
  98. package/lib/service/IssueReporter.js +2 -2
  99. package/lib/service/__tests__/IssueReporter.test.js +2 -2
  100. package/lib/service/getApiClient.js +14 -14
  101. package/lib/simple/Auth.js +404 -336
  102. package/lib/simple/Configuration.js +404 -336
  103. package/lib/simple/Directory.js +14 -14
  104. package/lib/simple/Phone.js +404 -336
  105. package/lib/simple/Websocket.js +18 -18
  106. package/lib/simple/index.js +408 -340
  107. package/lib/simple/room/LocalParticipant.js +408 -340
  108. package/lib/simple/room/Participant.js +408 -340
  109. package/lib/simple/room/RemoteParticipant.js +408 -340
  110. package/lib/simple/room/Room.js +409 -341
  111. package/lib/simple/room/SipRoom.js +408 -340
  112. package/lib/simple/room/Stream.js +408 -340
  113. package/lib/simple/room/__tests__/RemoteParticipant.test.js +408 -340
  114. package/lib/simple/utils.js +408 -340
  115. package/lib/utils/__tests__/api-requester.test.js +1 -1
  116. package/lib/utils/api-requester.js +1 -1
  117. package/lib/web-rtc-client.js +130 -108
  118. package/lib/websocket-client.js +16 -16
  119. package/package.json +1 -1
  120. package/src/domain/CallSession.js +16 -0
  121. package/src/domain/Contact.js +1 -1
  122. package/src/domain/Phone/WebRTCPhone.js +25 -4
  123. package/src/domain/SFUNotAvailableError.js +7 -0
  124. package/src/index.js +2 -0
  125. package/src/lib/WazoSessionDescriptionHandler.js +8 -3
  126. package/src/simple/Phone.js +2 -1
  127. package/src/simple/index.js +2 -0
  128. package/src/utils/api-requester.js +1 -1
  129. package/src/web-rtc-client.js +27 -10
@@ -253,8 +253,10 @@ var updateFrom = (instance , from ) => {
253
253
 
254
254
 
255
255
 
256
+
256
257
 
257
258
 
259
+
258
260
 
259
261
 
260
262
 
@@ -271,6 +273,7 @@ var updateFrom = (instance , from ) => {
271
273
 
272
274
 
273
275
 
276
+
274
277
 
275
278
 
276
279
  class CallSession {
@@ -290,8 +293,12 @@ class CallSession {
290
293
 
291
294
 
292
295
 
296
+
297
+
293
298
 
294
299
 
300
+
301
+
295
302
 
296
303
 
297
304
 
@@ -329,6 +336,8 @@ class CallSession {
329
336
 
330
337
 
331
338
 
339
+
340
+
332
341
 
333
342
  constructor({
334
343
  answered,
@@ -342,6 +351,8 @@ class CallSession {
342
351
  paused,
343
352
  ringing,
344
353
  startTime,
354
+ creationTime,
355
+ endTime,
345
356
  cameraEnabled,
346
357
  dialedExtension,
347
358
  sipCallId,
@@ -354,12 +365,15 @@ class CallSession {
354
365
  recording,
355
366
  recordingPaused,
356
367
  videoRemotelyDowngraded,
368
+ sipSession,
357
369
  } ) {
358
370
  this.callId = callId;
359
371
  this.sipCallId = sipCallId;
360
372
  this.displayName = displayName;
361
373
  this.number = number;
374
+ this.creationTime = creationTime;
362
375
  this.startTime = startTime;
376
+ this.endTime = endTime;
363
377
  this.isCaller = isCaller;
364
378
  this.answered = answered;
365
379
  this.answeredBySystem = answeredBySystem;
@@ -378,6 +392,7 @@ class CallSession {
378
392
  this.recording = recording || false;
379
393
  this.recordingPaused = recordingPaused || false;
380
394
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
395
+ this.sipSession = sipSession;
381
396
 
382
397
  // Useful to compare instead of instanceof with minified code
383
398
  this.type = 'CallSession';
@@ -1024,11 +1039,11 @@ var IssueReporter$1 = new IssueReporter();
1024
1039
 
1025
1040
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1026
1041
 
1027
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1042
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1028
1043
 
1029
1044
  // Use a function here to be able to mock it in tests
1030
1045
  const realFetch = () => {
1031
- if (typeof document !== 'undefined') {
1046
+ if (typeof document !== 'undefined' && window.fetch) {
1032
1047
  // Browser
1033
1048
  return window.fetch;
1034
1049
  }
@@ -1163,7 +1178,7 @@ class ApiRequester {
1163
1178
  };
1164
1179
 
1165
1180
  if (this.refreshTokenPromise) {
1166
- logger.info('A token is already refreshing, waiting ...', { url });
1181
+ logger$c.info('A token is already refreshing, waiting ...', { url });
1167
1182
  await this.refreshTokenPromise;
1168
1183
  }
1169
1184
 
@@ -1183,7 +1198,7 @@ class ApiRequester {
1183
1198
  return promise.then(async (err ) => {
1184
1199
  // Check if the token is still valid
1185
1200
  if (firstCall && this._checkTokenExpired(response, err)) {
1186
- logger.warn('token expired', { error: err.reason });
1201
+ logger$c.warn('token expired', { error: err.reason });
1187
1202
  // Replay the call after refreshing the token
1188
1203
  return this._replayWithNewToken(err, path, method, body, headers, parse);
1189
1204
  }
@@ -1193,7 +1208,7 @@ class ApiRequester {
1193
1208
  : exceptionClass.fromResponse(err, response.status);
1194
1209
 
1195
1210
  if (this.shouldLogErrors) {
1196
- logger.error('API error', error);
1211
+ logger$c.error('API error', error);
1197
1212
  }
1198
1213
 
1199
1214
  throw error;
@@ -1203,7 +1218,7 @@ class ApiRequester {
1203
1218
  return newParse(response, isJson);
1204
1219
  }).catch(error => {
1205
1220
  if (this.shouldLogErrors) {
1206
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
1221
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
1207
1222
  }
1208
1223
 
1209
1224
  throw error;
@@ -1231,13 +1246,13 @@ class ApiRequester {
1231
1246
  ) {
1232
1247
  const isTokenNotFound = this._isTokenNotFound(err);
1233
1248
  let newPath = path;
1234
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
1249
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
1235
1250
 
1236
1251
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
1237
1252
 
1238
1253
  return this.refreshTokenPromise.then(() => {
1239
1254
  this.refreshTokenPromise = null;
1240
- logger.info('token refreshed', { isTokenNotFound });
1255
+ logger$c.info('token refreshed', { isTokenNotFound });
1241
1256
  if (isTokenNotFound) {
1242
1257
  const pathParts = path.split('/');
1243
1258
  pathParts.pop();
@@ -2477,7 +2492,7 @@ class Contact {
2477
2492
  this[key] = old[key] || this[key];
2478
2493
  });
2479
2494
 
2480
- if (old.lineState && !this.lineState) {
2495
+ if (old.lineState) {
2481
2496
  this.lineState = old.lineState;
2482
2497
  }
2483
2498
 
@@ -4053,7 +4068,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4053
4068
 
4054
4069
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4055
4070
 
4056
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4071
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4057
4072
 
4058
4073
  class CTIPhone extends Emitter {
4059
4074
 
@@ -4066,7 +4081,7 @@ class CTIPhone extends Emitter {
4066
4081
 
4067
4082
  constructor(session , isMobile = false, callbackAllLines = false) {
4068
4083
  super();
4069
- logger$1.info('CTI Phone created');
4084
+ logger$b.info('CTI Phone created');
4070
4085
  this.session = session;
4071
4086
  this.isMobile = isMobile;
4072
4087
  this.callbackAllLines = callbackAllLines;
@@ -4127,7 +4142,7 @@ class CTIPhone extends Emitter {
4127
4142
  }
4128
4143
 
4129
4144
  async makeCall(number , line ) {
4130
- logger$1.info('make CTI call', { number });
4145
+ logger$b.info('make CTI call', { number });
4131
4146
 
4132
4147
  if (!number) {
4133
4148
  return null;
@@ -4150,7 +4165,7 @@ class CTIPhone extends Emitter {
4150
4165
  if (!callSession) {
4151
4166
  return Promise.resolve(null);
4152
4167
  }
4153
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4168
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4154
4169
 
4155
4170
  if (!this.currentCall) {
4156
4171
  this.currentCall = callSession.call;
@@ -4163,7 +4178,7 @@ class CTIPhone extends Emitter {
4163
4178
  if (!callSession) {
4164
4179
  return;
4165
4180
  }
4166
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4181
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4167
4182
 
4168
4183
  this.currentCall = undefined;
4169
4184
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4173,7 +4188,7 @@ class CTIPhone extends Emitter {
4173
4188
  if (!callSession) {
4174
4189
  return Promise.resolve(false);
4175
4190
  }
4176
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4191
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4177
4192
 
4178
4193
  try {
4179
4194
  await CallApi.cancelCall(callSession);
@@ -4184,7 +4199,7 @@ class CTIPhone extends Emitter {
4184
4199
  this.eventEmitter.emit('onCallEnded', callSession);
4185
4200
  return true;
4186
4201
  } catch (e) {
4187
- logger$1.error('hangup CTI call, error', e);
4202
+ logger$b.error('hangup CTI call, error', e);
4188
4203
 
4189
4204
  this.eventEmitter.emit('onCallFailed', callSession);
4190
4205
  return false;
@@ -4197,7 +4212,7 @@ class CTIPhone extends Emitter {
4197
4212
  if (!callSession) {
4198
4213
  return;
4199
4214
  }
4200
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4215
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4201
4216
 
4202
4217
  await CallApi.cancelCall(callSession);
4203
4218
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4207,7 +4222,7 @@ class CTIPhone extends Emitter {
4207
4222
  if (!callSession) {
4208
4223
  return;
4209
4224
  }
4210
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4225
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4211
4226
 
4212
4227
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4213
4228
  }
@@ -4220,19 +4235,19 @@ class CTIPhone extends Emitter {
4220
4235
  if (!callSession) {
4221
4236
  return;
4222
4237
  }
4223
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4238
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4224
4239
 
4225
4240
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4226
4241
  }
4227
4242
 
4228
4243
  async cancelCTIIndirectTransfer(transferId ) {
4229
- logger$1.info('cancel CTI transfer', { transferId });
4244
+ logger$b.info('cancel CTI transfer', { transferId });
4230
4245
 
4231
4246
  return CallApi.cancelCallTransfer(transferId);
4232
4247
  }
4233
4248
 
4234
4249
  async confirmCTIIndirectTransfer(transferId ) {
4235
- logger$1.info('confirm CTI transfer', { transferId });
4250
+ logger$b.info('confirm CTI transfer', { transferId });
4236
4251
 
4237
4252
  return CallApi.confirmCallTransfer(transferId);
4238
4253
  }
@@ -4241,19 +4256,19 @@ class CTIPhone extends Emitter {
4241
4256
  if (!callSession) {
4242
4257
  return;
4243
4258
  }
4244
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4259
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4245
4260
 
4246
4261
  return CallApi.sendDTMF(callSession.callId, digits);
4247
4262
  }
4248
4263
 
4249
4264
  onConnectionMade() {
4250
- logger$1.info('on CTI connection made');
4265
+ logger$b.info('on CTI connection made');
4251
4266
 
4252
4267
  this.eventEmitter.emit('onCallAccepted');
4253
4268
  }
4254
4269
 
4255
4270
  async close() {
4256
- logger$1.info('CTI close');
4271
+ logger$b.info('CTI close');
4257
4272
 
4258
4273
  return Promise.resolve();
4259
4274
  }
@@ -4262,7 +4277,7 @@ class CTIPhone extends Emitter {
4262
4277
  if (!callSession) {
4263
4278
  return;
4264
4279
  }
4265
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4280
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4266
4281
 
4267
4282
  return CallApi.hold(callSession.callId);
4268
4283
  }
@@ -4271,7 +4286,7 @@ class CTIPhone extends Emitter {
4271
4286
  if (!callSession) {
4272
4287
  return;
4273
4288
  }
4274
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4289
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4275
4290
 
4276
4291
  return CallApi.resume(callSession.callId);
4277
4292
  }
@@ -4280,7 +4295,7 @@ class CTIPhone extends Emitter {
4280
4295
  if (!callSession) {
4281
4296
  return;
4282
4297
  }
4283
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4298
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4284
4299
 
4285
4300
  return CallApi.mute(callSession.callId);
4286
4301
  }
@@ -4289,7 +4304,7 @@ class CTIPhone extends Emitter {
4289
4304
  if (!callSession) {
4290
4305
  return;
4291
4306
  }
4292
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4307
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4293
4308
 
4294
4309
  return CallApi.unmute(callSession.callId);
4295
4310
  }
@@ -5298,7 +5313,7 @@ const AGENTD_VERSION = '1.0';
5298
5313
  const WEBHOOKD_VERSION = '1.0';
5299
5314
  const AMID_VERSION = '1.0';
5300
5315
 
5301
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5316
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5302
5317
 
5303
5318
  class ApiClient {
5304
5319
 
@@ -5350,12 +5365,12 @@ class ApiClient {
5350
5365
  }
5351
5366
 
5352
5367
  async forceRefreshToken() {
5353
- logger$2.info('forcing refresh token, calling callback');
5368
+ logger$a.info('forcing refresh token, calling callback');
5354
5369
  return this.refreshTokenCallback();
5355
5370
  }
5356
5371
 
5357
5372
  async refreshTokenCallback() {
5358
- logger$2.info('refresh token callback called', {
5373
+ logger$a.info('refresh token callback called', {
5359
5374
  refreshToken: this.refreshToken,
5360
5375
  refreshBackend: this.refreshBackend,
5361
5376
  refreshExpiration: this.refreshExpiration,
@@ -5373,7 +5388,7 @@ class ApiClient {
5373
5388
  this.isMobile,
5374
5389
  );
5375
5390
 
5376
- logger$2.info('token refreshed', { token: session.token });
5391
+ logger$a.info('token refreshed', { token: session.token });
5377
5392
 
5378
5393
  if (this.onRefreshToken) {
5379
5394
  this.onRefreshToken(session.token, session);
@@ -5686,7 +5701,7 @@ class AdHocAPIConference {
5686
5701
 
5687
5702
  /* */
5688
5703
 
5689
- const parseCandidate = (candidate ) => {
5704
+ const parseCandidate$1 = (candidate ) => {
5690
5705
  if (!candidate) {
5691
5706
  return null;
5692
5707
  }
@@ -5798,11 +5813,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5798
5813
 
5799
5814
  // $FlowFixMe
5800
5815
  setRemoteSessionDescription(sessionDescription ) {
5801
- const result = super.setRemoteSessionDescription(sessionDescription);
5816
+ try {
5817
+ const result = super.setRemoteSessionDescription(sessionDescription);
5802
5818
 
5803
- this.eventEmitter.emit('setDescription', sessionDescription);
5819
+ this.eventEmitter.emit('setDescription', sessionDescription);
5804
5820
 
5805
- return result;
5821
+ return result;
5822
+ } catch (error) {
5823
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5824
+ throw error;
5825
+ }
5806
5826
  }
5807
5827
 
5808
5828
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -5840,7 +5860,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5840
5860
  this.peerConnectionDelegate.onicecandidate = event => {
5841
5861
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5842
5862
  if (event.candidate) {
5843
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5863
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5844
5864
  }
5845
5865
  };
5846
5866
 
@@ -6304,7 +6324,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6304
6324
  const SEND_STATS_DELAY = 5000;
6305
6325
 
6306
6326
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6307
- const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6327
+ const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6308
6328
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6309
6329
 
6310
6330
  // events
@@ -6318,14 +6338,14 @@ const TRANSPORT_ERROR = 'transportError';
6318
6338
  const MESSAGE = 'message';
6319
6339
  const ACCEPTED = 'accepted';
6320
6340
  const REJECTED = 'rejected';
6321
- const ON_TRACK = 'onTrack';
6322
- const ON_REINVITE = 'reinvite';
6341
+ const ON_TRACK$1 = 'onTrack';
6342
+ const ON_REINVITE$1 = 'reinvite';
6323
6343
  const ON_ERROR = 'onError';
6324
6344
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6325
- const ON_NETWORK_STATS = 'onNetworkStats';
6326
- const ON_DISCONNECTED = 'onDisconnected';
6345
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6346
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6327
6347
 
6328
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6348
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6329
6349
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6330
6350
  class CanceledCallError extends Error {}
6331
6351
 
@@ -6461,12 +6481,12 @@ class WebRTCClient extends Emitter {
6461
6481
  this.MESSAGE = MESSAGE;
6462
6482
  this.ACCEPTED = ACCEPTED;
6463
6483
  this.REJECTED = REJECTED;
6464
- this.ON_TRACK = ON_TRACK;
6465
- this.ON_REINVITE = ON_REINVITE;
6484
+ this.ON_TRACK = ON_TRACK$1;
6485
+ this.ON_REINVITE = ON_REINVITE$1;
6466
6486
  this.ON_ERROR = ON_ERROR;
6467
6487
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6468
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6469
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6488
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6489
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6470
6490
  }
6471
6491
 
6472
6492
  configureMedia(media ) {
@@ -6483,13 +6503,13 @@ class WebRTCClient extends Emitter {
6483
6503
 
6484
6504
  createUserAgent(configOverrides ) {
6485
6505
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6486
- logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6506
+ logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6487
6507
 
6488
6508
  webRTCConfiguration.delegate = {
6489
6509
  onConnect: this.onConnect.bind(this),
6490
6510
  onDisconnect: this.onDisconnect.bind(this),
6491
6511
  onInvite: (invitation ) => {
6492
- logger$3.info('sdk webrtc on invite', {
6512
+ logger$9.info('sdk webrtc on invite', {
6493
6513
  method: 'delegate.onInvite',
6494
6514
  id: invitation.id,
6495
6515
  remoteURI: invitation.remoteURI,
@@ -6532,7 +6552,7 @@ class WebRTCClient extends Emitter {
6532
6552
  }
6533
6553
 
6534
6554
  onConnect() {
6535
- logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6555
+ logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6536
6556
  this.eventEmitter.emit(CONNECTED);
6537
6557
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6538
6558
  this.registerer.waitingToggle(false);
@@ -6541,7 +6561,7 @@ class WebRTCClient extends Emitter {
6541
6561
  }
6542
6562
 
6543
6563
  async onDisconnect(error ) {
6544
- logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6564
+ logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6545
6565
  this.connectionPromise = null;
6546
6566
  // The UA will attempt to reconnect automatically when an error occurred
6547
6567
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6566,37 +6586,37 @@ class WebRTCClient extends Emitter {
6566
6586
  };
6567
6587
 
6568
6588
  if (this.skipRegister) {
6569
- logger$3.info('sdk webrtc skip register...', logInfo);
6589
+ logger$9.info('sdk webrtc skip register...', logInfo);
6570
6590
  return Promise.resolve();
6571
6591
  }
6572
6592
 
6573
- logger$3.info('sdk webrtc registering...', logInfo);
6593
+ logger$9.info('sdk webrtc registering...', logInfo);
6574
6594
 
6575
6595
  if (!this.userAgent) {
6576
- logger$3.info('sdk webrtc recreating User Agent');
6596
+ logger$9.info('sdk webrtc recreating User Agent');
6577
6597
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6578
6598
  }
6579
6599
  if (!this.userAgent || this.isRegistered()) {
6580
- logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6600
+ logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6581
6601
  return Promise.resolve();
6582
6602
  }
6583
6603
 
6584
6604
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6585
- logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6605
+ logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6586
6606
  return Promise.resolve();
6587
6607
  }
6588
6608
 
6589
6609
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6590
6610
 
6591
6611
  const onRegisterFailed = () => {
6592
- logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6612
+ logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6593
6613
  this.connectionPromise = null;
6594
6614
  if (this.registerer && this.registerer.waiting) {
6595
6615
  this.registerer.waitingToggle(false);
6596
6616
  }
6597
6617
 
6598
6618
  if (tries <= MAX_REGISTER_TRIES) {
6599
- logger$3.info('sdk webrtc registering, retrying...', { tries });
6619
+ logger$9.info('sdk webrtc registering, retrying...', { tries });
6600
6620
  setTimeout(() => this.register(tries + 1), 300);
6601
6621
  }
6602
6622
  };
@@ -6605,18 +6625,18 @@ class WebRTCClient extends Emitter {
6605
6625
  // Avoid race condition with the close method called just before register and setting userAgent to null
6606
6626
  // during the resolution of the primise.
6607
6627
  if (!this.userAgent) {
6608
- logger$3.info('sdk webrtc recreating User Agent after connection');
6628
+ logger$9.info('sdk webrtc recreating User Agent after connection');
6609
6629
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6610
6630
  }
6611
6631
 
6612
- logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6632
+ logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6613
6633
  this.registerer = new Registerer(this.userAgent, registerOptions);
6614
6634
  this.connectionPromise = null;
6615
6635
  this._monkeyPatchRegisterer(this.registerer);
6616
6636
 
6617
6637
  // Bind registerer events
6618
6638
  this.registerer.stateChange.addListener(newState => {
6619
- logger$3.info('sdk webrtc registering, state changed', { newState });
6639
+ logger$9.info('sdk webrtc registering, state changed', { newState });
6620
6640
 
6621
6641
  if (newState === RegistererState.Registered && this.registerer
6622
6642
  && this.registerer.state === RegistererState.Registered) {
@@ -6629,7 +6649,7 @@ class WebRTCClient extends Emitter {
6629
6649
  const options = {
6630
6650
  requestDelegate: {
6631
6651
  onReject: response => {
6632
- logger$3.error('sdk webrtc registering, rejected', { response });
6652
+ logger$9.error('sdk webrtc registering, rejected', { response });
6633
6653
 
6634
6654
  onRegisterFailed();
6635
6655
  },
@@ -6637,13 +6657,13 @@ class WebRTCClient extends Emitter {
6637
6657
  };
6638
6658
 
6639
6659
  return this.registerer.register(options).catch((e) => {
6640
- logger$3.error('sdk webrtc registering, error', e);
6660
+ logger$9.error('sdk webrtc registering, error', e);
6641
6661
 
6642
6662
  this.eventEmitter.emit(REGISTRATION_FAILED);
6643
6663
  return e;
6644
6664
  });
6645
6665
  }).catch(error => {
6646
- logger$3.error('sdk webrtc registering, transport error', error);
6666
+ logger$9.error('sdk webrtc registering, transport error', error);
6647
6667
  onRegisterFailed();
6648
6668
  });
6649
6669
  }
@@ -6672,21 +6692,21 @@ class WebRTCClient extends Emitter {
6672
6692
  }
6673
6693
 
6674
6694
  unregister() {
6675
- logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6695
+ logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6676
6696
  if (!this.registerer) {
6677
6697
  return Promise.resolve();
6678
6698
  }
6679
6699
 
6680
6700
  try {
6681
6701
  return this.registerer.unregister().then(() => {
6682
- logger$3.info('sdk webrtc unregistered');
6702
+ logger$9.info('sdk webrtc unregistered');
6683
6703
  this._cleanupRegister();
6684
6704
  }).catch(e => {
6685
- logger$3.error('sdk webrtc unregistering, promise error', e);
6705
+ logger$9.error('sdk webrtc unregistering, promise error', e);
6686
6706
  this._cleanupRegister();
6687
6707
  });
6688
6708
  } catch (e) {
6689
- logger$3.error('sdk webrtc unregistering, error', e);
6709
+ logger$9.error('sdk webrtc unregistering, error', e);
6690
6710
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6691
6711
  // error when the registerer is in a bad state
6692
6712
  this._cleanupRegister();
@@ -6694,7 +6714,7 @@ class WebRTCClient extends Emitter {
6694
6714
  }
6695
6715
 
6696
6716
  stop() {
6697
- logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6717
+ logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6698
6718
  if (!this.userAgent) {
6699
6719
  return Promise.resolve();
6700
6720
  }
@@ -6702,12 +6722,12 @@ class WebRTCClient extends Emitter {
6702
6722
  return this.userAgent.stop().then(() => {
6703
6723
  return this._cleanupRegister();
6704
6724
  }).catch(e => {
6705
- logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6725
+ logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6706
6726
  });
6707
6727
  }
6708
6728
 
6709
6729
  call(number , enableVideo , audioOnly = false, conference = false) {
6710
- logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6730
+ logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6711
6731
  const inviterOptions = {
6712
6732
  sessionDescriptionHandlerOptionsReInvite: {
6713
6733
  conference,
@@ -6738,7 +6758,7 @@ class WebRTCClient extends Emitter {
6738
6758
  this._onAccepted(session, response.session, true);
6739
6759
  },
6740
6760
  onReject: (response ) => {
6741
- logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6761
+ logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6742
6762
  this._stopSendingStats(session);
6743
6763
  this.stopNetworkMonitoring(session);
6744
6764
 
@@ -6761,11 +6781,11 @@ class WebRTCClient extends Emitter {
6761
6781
  }
6762
6782
 
6763
6783
  answer(session , enableVideo ) {
6764
- logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6784
+ logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6765
6785
 
6766
6786
  if (!session || !session.accept) {
6767
6787
  const error = 'No session to answer, or not an invitation';
6768
- logger$3.warn(error);
6788
+ logger$9.warn(error);
6769
6789
  return Promise.reject(new Error(error));
6770
6790
  }
6771
6791
  const options = {
@@ -6775,15 +6795,15 @@ class WebRTCClient extends Emitter {
6775
6795
  return session.accept(options).then(() => {
6776
6796
  if (session.isCanceled) {
6777
6797
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6778
- logger$3.error(message, { id: session.id });
6798
+ logger$9.error(message, { id: session.id });
6779
6799
  this.onCallEnded(session);
6780
6800
 
6781
6801
  throw new CanceledCallError(message);
6782
6802
  }
6783
- logger$3.info('sdk webrtc answer, accepted.');
6803
+ logger$9.info('sdk webrtc answer, accepted.');
6784
6804
  this._onAccepted(session);
6785
6805
  }).catch(e => {
6786
- logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6806
+ logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6787
6807
 
6788
6808
  throw e;
6789
6809
  });
@@ -6791,7 +6811,7 @@ class WebRTCClient extends Emitter {
6791
6811
 
6792
6812
  hangup(session ) {
6793
6813
  const { state, id } = session;
6794
- logger$3.info('sdk webrtc hangup call', { id, state });
6814
+ logger$9.info('sdk webrtc hangup call', { id, state });
6795
6815
 
6796
6816
  try {
6797
6817
  this._stopSendingStats(session);
@@ -6820,7 +6840,7 @@ class WebRTCClient extends Emitter {
6820
6840
 
6821
6841
  return bye();
6822
6842
  } catch (error) {
6823
- logger$3.warn('sdk webrtc hangup, error', error);
6843
+ logger$9.warn('sdk webrtc hangup, error', error);
6824
6844
  }
6825
6845
 
6826
6846
  return null;
@@ -6838,7 +6858,7 @@ class WebRTCClient extends Emitter {
6838
6858
  // Fetch and emit an event at `interval` with session network stats
6839
6859
  startNetworkMonitoring(session , interval = 1000) {
6840
6860
  const sessionId = this.getSipSessionId(session);
6841
- logger$3.info('starting network inspection', { id: sessionId });
6861
+ logger$9.info('starting network inspection', { id: sessionId });
6842
6862
 
6843
6863
  this.sessionNetworkStats[sessionId] = [];
6844
6864
 
@@ -6848,7 +6868,7 @@ class WebRTCClient extends Emitter {
6848
6868
  stopNetworkMonitoring(session ) {
6849
6869
  const sessionId = this.getSipSessionId(session);
6850
6870
  const exists = sessionId in this.networkMonitoringInterval;
6851
- logger$3.info('stopping network inspection', { id: sessionId, exists });
6871
+ logger$9.info('stopping network inspection', { id: sessionId, exists });
6852
6872
 
6853
6873
  if (exists) {
6854
6874
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6858,17 +6878,17 @@ class WebRTCClient extends Emitter {
6858
6878
  }
6859
6879
 
6860
6880
  reject(session ) {
6861
- logger$3.info('sdk webrtc reject call', { id: session.id });
6881
+ logger$9.info('sdk webrtc reject call', { id: session.id });
6862
6882
 
6863
6883
  try {
6864
6884
  return session.reject ? session.reject() : session.cancel();
6865
6885
  } catch (e) {
6866
- logger$3.warn('Error when rejecting call', e.message, e.stack);
6886
+ logger$9.warn('Error when rejecting call', e.message, e.stack);
6867
6887
  }
6868
6888
  }
6869
6889
 
6870
6890
  async close() {
6871
- logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6891
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6872
6892
  this._cleanupMedia();
6873
6893
  this.connectionPromise = null;
6874
6894
 
@@ -6899,7 +6919,7 @@ class WebRTCClient extends Emitter {
6899
6919
  // eg: "INVITE not rejectable in state Completed"
6900
6920
  }
6901
6921
  this.userAgent = null;
6902
- logger$3.info('sdk webrtc client closed');
6922
+ logger$9.info('sdk webrtc client closed');
6903
6923
  }
6904
6924
 
6905
6925
  getNumber(session ) {
@@ -6912,13 +6932,13 @@ class WebRTCClient extends Emitter {
6912
6932
  }
6913
6933
 
6914
6934
  mute(session ) {
6915
- logger$3.info('sdk webrtc mute', { id: session.id });
6935
+ logger$9.info('sdk webrtc mute', { id: session.id });
6916
6936
 
6917
6937
  this._toggleAudio(session, true);
6918
6938
  }
6919
6939
 
6920
6940
  unmute(session ) {
6921
- logger$3.info('sdk webrtc unmute', { id: session.id });
6941
+ logger$9.info('sdk webrtc unmute', { id: session.id });
6922
6942
 
6923
6943
  this._toggleAudio(session, false);
6924
6944
  }
@@ -6958,13 +6978,13 @@ class WebRTCClient extends Emitter {
6958
6978
  }
6959
6979
 
6960
6980
  toggleCameraOn(session ) {
6961
- logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6981
+ logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6962
6982
 
6963
6983
  this._toggleVideo(session, false);
6964
6984
  }
6965
6985
 
6966
6986
  toggleCameraOff(session ) {
6967
- logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6987
+ logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6968
6988
 
6969
6989
  this._toggleVideo(session, true);
6970
6990
  }
@@ -6973,7 +6993,7 @@ class WebRTCClient extends Emitter {
6973
6993
  const sessionId = this.getSipSessionId(session);
6974
6994
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6975
6995
 
6976
- logger$3.info('sdk webrtc hold', {
6996
+ logger$9.info('sdk webrtc hold', {
6977
6997
  sessionId,
6978
6998
  keys: Object.keys(this.heldSessions),
6979
6999
  pendingReinvite: !!session.pendingReinvite,
@@ -7022,7 +7042,7 @@ class WebRTCClient extends Emitter {
7022
7042
  const sessionId = this.getSipSessionId(session);
7023
7043
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7024
7044
 
7025
- logger$3.info('sdk webrtc unhold', {
7045
+ logger$9.info('sdk webrtc unhold', {
7026
7046
  sessionId,
7027
7047
  keys: Object.keys(this.heldSessions),
7028
7048
  pendingReinvite: !!session.pendingReinvite,
@@ -7170,7 +7190,7 @@ class WebRTCClient extends Emitter {
7170
7190
  if (!session.sessionDescriptionHandler) {
7171
7191
  return;
7172
7192
  }
7173
- logger$3.info('Sending DTMF', {
7193
+ logger$9.info('Sending DTMF', {
7174
7194
  id: this.getSipSessionId(session),
7175
7195
  tone,
7176
7196
  });
@@ -7186,7 +7206,7 @@ class WebRTCClient extends Emitter {
7186
7206
  transfer(session , target ) {
7187
7207
  this.hold(session);
7188
7208
 
7189
- logger$3.info('Transfering a session', {
7209
+ logger$9.info('Transfering a session', {
7190
7210
  id: this.getSipSessionId(session),
7191
7211
  target,
7192
7212
  });
@@ -7208,17 +7228,17 @@ class WebRTCClient extends Emitter {
7208
7228
  atxfer(session ) {
7209
7229
  this.hold(session);
7210
7230
 
7211
- logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7231
+ logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7212
7232
 
7213
7233
  const result = {
7214
7234
  newSession: null,
7215
7235
  init: async (target ) => {
7216
- logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7236
+ logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7217
7237
 
7218
7238
  result.newSession = await this.call(target);
7219
7239
  },
7220
7240
  complete: () => {
7221
- logger$3.info('webrtc transfer completed', {
7241
+ logger$9.info('webrtc transfer completed', {
7222
7242
  id: this.getSipSessionId(session),
7223
7243
  referId: this.getSipSessionId(result.newSession),
7224
7244
  });
@@ -7239,7 +7259,7 @@ class WebRTCClient extends Emitter {
7239
7259
  return;
7240
7260
  }
7241
7261
 
7242
- logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7262
+ logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7243
7263
 
7244
7264
  try {
7245
7265
  sipSession.message({
@@ -7281,7 +7301,7 @@ class WebRTCClient extends Emitter {
7281
7301
  }
7282
7302
 
7283
7303
  changeAudioOutputVolume(volume ) {
7284
- logger$3.info('Changing audio output volume', { volume });
7304
+ logger$9.info('Changing audio output volume', { volume });
7285
7305
 
7286
7306
  Object.values(this.audioElements).forEach(audioElement => {
7287
7307
  if (audioElement instanceof HTMLAudioElement) {
@@ -7293,7 +7313,7 @@ class WebRTCClient extends Emitter {
7293
7313
  }
7294
7314
 
7295
7315
  changeAudioOutputDevice(id ) {
7296
- logger$3.info('Changing audio output device', { id });
7316
+ logger$9.info('Changing audio output device', { id });
7297
7317
 
7298
7318
  Object.values(this.audioElements).forEach(audioElement => {
7299
7319
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7310,7 +7330,7 @@ class WebRTCClient extends Emitter {
7310
7330
 
7311
7331
  changeAudioInputDevice(id , session ) {
7312
7332
  const currentId = this.getAudioDeviceId();
7313
- logger$3.info('setting audio input device', { id, currentId, session: !!session });
7333
+ logger$9.info('setting audio input device', { id, currentId, session: !!session });
7314
7334
 
7315
7335
  if (id === currentId) {
7316
7336
  return null;
@@ -7356,7 +7376,7 @@ class WebRTCClient extends Emitter {
7356
7376
 
7357
7377
  setVideoInputDevice(id ) {
7358
7378
  const currentId = this.getVideoDeviceId();
7359
- logger$3.info('setting video input device', { id, currentId });
7379
+ logger$9.info('setting video input device', { id, currentId });
7360
7380
 
7361
7381
  if (id === currentId) {
7362
7382
  return null;
@@ -7381,7 +7401,7 @@ class WebRTCClient extends Emitter {
7381
7401
  const sessionId = this.getSipSessionId(session);
7382
7402
  const localStream = this.getLocalStream(sessionId);
7383
7403
 
7384
- logger$3.info('changing video input device', { id, sessionId });
7404
+ logger$9.info('changing video input device', { id, sessionId });
7385
7405
 
7386
7406
  // Release old video stream
7387
7407
  if (localStream) {
@@ -7449,7 +7469,7 @@ class WebRTCClient extends Emitter {
7449
7469
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7450
7470
  const desktop = newConstraints && newConstraints.desktop;
7451
7471
 
7452
- logger$3.info('Sending reinvite', {
7472
+ logger$9.info('Sending reinvite', {
7453
7473
  id: this.getSipSessionId(sipSession),
7454
7474
  newConstraints,
7455
7475
  conference,
@@ -7487,7 +7507,7 @@ class WebRTCClient extends Emitter {
7487
7507
  sipSession.incomingInviteRequest.message.body = response.message.body;
7488
7508
  }
7489
7509
 
7490
- logger$3.info('on re-INVITE accepted', {
7510
+ logger$9.info('on re-INVITE accepted', {
7491
7511
  id: this.getSipSessionId(sipSession),
7492
7512
  wasMuted,
7493
7513
  shouldDoScreenSharing,
@@ -7505,7 +7525,7 @@ class WebRTCClient extends Emitter {
7505
7525
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7506
7526
  }
7507
7527
 
7508
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7528
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7509
7529
  },
7510
7530
  },
7511
7531
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7662,7 +7682,7 @@ class WebRTCClient extends Emitter {
7662
7682
  }
7663
7683
 
7664
7684
  startHeartbeat() {
7665
- logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7685
+ logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7666
7686
  if (!this.userAgent) {
7667
7687
  this.heartbeat.stop();
7668
7688
  return;
@@ -7675,7 +7695,7 @@ class WebRTCClient extends Emitter {
7675
7695
  }
7676
7696
 
7677
7697
  stopHeartbeat() {
7678
- logger$3.info('sdk webrtc stop heartbeat');
7698
+ logger$9.info('sdk webrtc stop heartbeat');
7679
7699
  this.heartbeat.stop();
7680
7700
  }
7681
7701
 
@@ -7696,7 +7716,7 @@ class WebRTCClient extends Emitter {
7696
7716
  }
7697
7717
 
7698
7718
  attemptReconnection() {
7699
- logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7719
+ logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7700
7720
  if (!this.userAgent) {
7701
7721
  return;
7702
7722
  }
@@ -7721,7 +7741,7 @@ class WebRTCClient extends Emitter {
7721
7741
  return;
7722
7742
  }
7723
7743
 
7724
- logger$3.info('setting local media stream', {
7744
+ logger$9.info('setting local media stream', {
7725
7745
  sipSessionId,
7726
7746
  tracks: newStream ? newStream.getTracks() : null,
7727
7747
  });
@@ -7738,7 +7758,7 @@ class WebRTCClient extends Emitter {
7738
7758
 
7739
7759
  const oldStream = this.getLocalStream(sipSessionId);
7740
7760
 
7741
- logger$3.info('updating local stream', {
7761
+ logger$9.info('updating local stream', {
7742
7762
  sipSessionId,
7743
7763
  oldStream: !!oldStream,
7744
7764
  tracks: newStream.getTracks(),
@@ -7758,7 +7778,7 @@ class WebRTCClient extends Emitter {
7758
7778
  const remoteStream = this.getRemoteStream(sessionId);
7759
7779
  const pc = this.getPeerConnection(sessionId);
7760
7780
 
7761
- logger$3.info('Updating remote stream', {
7781
+ logger$9.info('Updating remote stream', {
7762
7782
  sessionId,
7763
7783
  tracks: remoteStream ? remoteStream.getTracks() : null,
7764
7784
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7783,14 +7803,16 @@ class WebRTCClient extends Emitter {
7783
7803
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7784
7804
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7785
7805
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7806
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7786
7807
 
7787
- logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7808
+ logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7788
7809
 
7789
7810
  return {
7790
7811
  constraints: {
7791
7812
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7792
7813
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7793
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7814
+ video: screenSharing ? (isDesktop
7815
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7794
7816
  : this._getVideoConstraints(enableVideo),
7795
7817
  screen: screenSharing,
7796
7818
  desktop: isDesktop,
@@ -7833,7 +7855,7 @@ class WebRTCClient extends Emitter {
7833
7855
  }
7834
7856
 
7835
7857
  _onTransportError() {
7836
- logger$3.error('on transport error');
7858
+ logger$9.error('on transport error');
7837
7859
  this.eventEmitter.emit(TRANSPORT_ERROR);
7838
7860
  this.attemptReconnection();
7839
7861
  }
@@ -7842,7 +7864,7 @@ class WebRTCClient extends Emitter {
7842
7864
  const body = message && typeof message === 'object' ? message.data : message;
7843
7865
  if (body && body.indexOf('200 OK') !== -1) {
7844
7866
  if (this.hasHeartbeat()) {
7845
- logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7867
+ logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7846
7868
 
7847
7869
  this.heartbeat.onHeartbeat();
7848
7870
  if (this.heartbeatCb) {
@@ -7853,7 +7875,7 @@ class WebRTCClient extends Emitter {
7853
7875
  }
7854
7876
 
7855
7877
  async _onHeartbeatTimeout() {
7856
- logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7878
+ logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7857
7879
 
7858
7880
  if (this.heartbeatTimeoutCb) {
7859
7881
  this.heartbeatTimeoutCb();
@@ -7865,7 +7887,7 @@ class WebRTCClient extends Emitter {
7865
7887
  try {
7866
7888
  await this.userAgent.transport.disconnect();
7867
7889
  } catch (e) {
7868
- logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7890
+ logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7869
7891
  }
7870
7892
  }
7871
7893
 
@@ -7898,31 +7920,31 @@ class WebRTCClient extends Emitter {
7898
7920
  }
7899
7921
 
7900
7922
  _connectIfNeeded() {
7901
- logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7923
+ logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7902
7924
  if (!this.userAgent) {
7903
- logger$3.info('need to recreate User Agent');
7925
+ logger$9.info('need to recreate User Agent');
7904
7926
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7905
7927
  }
7906
7928
 
7907
7929
  if (this.isConnected()) {
7908
- logger$3.info('webrtc sdk, already connected');
7930
+ logger$9.info('webrtc sdk, already connected');
7909
7931
  return Promise.resolve();
7910
7932
  }
7911
7933
 
7912
7934
  if (this.isConnecting()) {
7913
- logger$3.info('webrtc sdk, already connecting...');
7935
+ logger$9.info('webrtc sdk, already connecting...');
7914
7936
 
7915
7937
  this.connectionPromise = this.userAgent.transport.connectPromise;
7916
7938
  return this.connectionPromise;
7917
7939
  }
7918
7940
 
7919
7941
  if (this.connectionPromise) {
7920
- logger$3.info('webrtc sdk, connection promise connecting...');
7942
+ logger$9.info('webrtc sdk, connection promise connecting...');
7921
7943
  // $FlowFixMe
7922
7944
  return this.connectionPromise;
7923
7945
  }
7924
7946
 
7925
- logger$3.info('WebRTC UA needs to connect');
7947
+ logger$9.info('WebRTC UA needs to connect');
7926
7948
 
7927
7949
  // Force UA to reconnect
7928
7950
  if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
@@ -8047,7 +8069,7 @@ class WebRTCClient extends Emitter {
8047
8069
 
8048
8070
  sdh.peerConnectionDelegate = {
8049
8071
  onicecandidateerror: (error ) => {
8050
- logger$3.error('on icecandidate error', {
8072
+ logger$9.error('on icecandidate error', {
8051
8073
  address: error.address,
8052
8074
  port: error.port,
8053
8075
  errorCode: error.errorCode,
@@ -8076,7 +8098,7 @@ class WebRTCClient extends Emitter {
8076
8098
  updatedNumber = session.assertedIdentity.uri.normal.user;
8077
8099
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8078
8100
  }
8079
- logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8101
+ logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8080
8102
 
8081
8103
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8082
8104
 
@@ -8092,12 +8114,12 @@ class WebRTCClient extends Emitter {
8092
8114
 
8093
8115
  this._setupMedias(session);
8094
8116
 
8095
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8117
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8096
8118
  };
8097
8119
  }
8098
8120
 
8099
8121
  _onAccepted(session , sessionDialog , withEvent = true) {
8100
- logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8122
+ logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8101
8123
 
8102
8124
  this.storeSipSession(session);
8103
8125
 
@@ -8109,14 +8131,14 @@ class WebRTCClient extends Emitter {
8109
8131
  const onTrack = (event ) => {
8110
8132
  const isAudioOnly = this._isAudioOnly(session);
8111
8133
  const { kind, label, readyState, id, muted } = event.track;
8112
- logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8134
+ logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8113
8135
 
8114
8136
  // Stop video track in audio only mode
8115
8137
  if (isAudioOnly && kind === 'video') {
8116
8138
  event.track.stop();
8117
8139
  }
8118
8140
 
8119
- this.eventEmitter.emit(ON_TRACK, session, event);
8141
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
8120
8142
  };
8121
8143
 
8122
8144
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8125,12 +8147,14 @@ class WebRTCClient extends Emitter {
8125
8147
 
8126
8148
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8127
8149
 
8128
- pc.oniceconnectionstatechange = () => {
8129
- logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
8130
- if (pc.iceConnectionState === 'disconnected') {
8131
- this.eventEmitter.emit(ON_DISCONNECTED);
8132
- }
8133
- };
8150
+ if (pc) {
8151
+ pc.oniceconnectionstatechange = () => {
8152
+ logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
8153
+ if (pc.iceConnectionState === 'disconnected') {
8154
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8155
+ }
8156
+ };
8157
+ }
8134
8158
 
8135
8159
  if (withEvent) {
8136
8160
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8299,10 +8323,10 @@ class WebRTCClient extends Emitter {
8299
8323
 
8300
8324
  _stopSendingStats(session ) {
8301
8325
  const sessionId = this.getSipSessionId(session);
8302
- logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8326
+ logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8303
8327
 
8304
8328
  if (sessionId in this.statsIntervals) {
8305
- logger$3.trace('Stop sending stats for call', { sessionId });
8329
+ logger$9.trace('Stop sending stats for call', { sessionId });
8306
8330
  this.statsIntervals[sessionId]();
8307
8331
  delete this.statsIntervals[sessionId];
8308
8332
  }
@@ -8318,7 +8342,7 @@ class WebRTCClient extends Emitter {
8318
8342
  try {
8319
8343
  await this.userAgent.transport.disconnect();
8320
8344
  } catch (e) {
8321
- logger$3.error('WebRTC transport disconnect, error', e);
8345
+ logger$9.error('WebRTC transport disconnect, error', e);
8322
8346
  }
8323
8347
  }
8324
8348
  }
@@ -8340,13 +8364,17 @@ class WebRTCClient extends Emitter {
8340
8364
  const nbStats = this.sessionNetworkStats[sessionId].length;
8341
8365
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8342
8366
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8367
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8343
8368
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8344
8369
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8370
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8345
8371
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8346
8372
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8347
8373
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8348
- let audioBytesSent = 0;
8349
- let audioBytesReceived = 0;
8374
+ let audioBytesSent = 0; // content + header
8375
+ let audioBytesReceived = 0; // content + header
8376
+ let audioContentSent = 0; // useful to detect blank call
8377
+ let audioContentReceived = 0;
8350
8378
  let videoBytesSent = 0;
8351
8379
  let videoBytesReceived = 0;
8352
8380
  let transportSent = 0;
@@ -8356,6 +8384,7 @@ class WebRTCClient extends Emitter {
8356
8384
  stats.forEach(report => {
8357
8385
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8358
8386
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8387
+ audioContentSent += Number(report.bytesSent);
8359
8388
  }
8360
8389
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8361
8390
  audioBytesSent += Number(report.bytesSent);
@@ -8367,6 +8396,7 @@ class WebRTCClient extends Emitter {
8367
8396
  packetsLost += Number(report.packetsLost);
8368
8397
  networkStats.packetsReceived = Number(report.packetsReceived);
8369
8398
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8399
+ audioContentReceived += Number(report.bytesReceived);
8370
8400
  }
8371
8401
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8372
8402
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8395,10 +8425,17 @@ class WebRTCClient extends Emitter {
8395
8425
  });
8396
8426
 
8397
8427
  networkStats.packetsLost = packetsLost;
8428
+
8398
8429
  networkStats.totalAudioBytesSent = audioBytesSent;
8399
8430
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8400
8431
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8401
8432
  networkStats.audioBytesReceived = audioBytesReceived;
8433
+
8434
+ networkStats.totalAudioContentSent = audioContentSent;
8435
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8436
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8437
+ networkStats.audioContentReceived = audioContentReceived;
8438
+
8402
8439
  networkStats.totalVideoBytesSent = videoBytesSent;
8403
8440
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8404
8441
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8412,7 +8449,7 @@ class WebRTCClient extends Emitter {
8412
8449
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8413
8450
  + networkStats.transportSent;
8414
8451
 
8415
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8452
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8416
8453
  this.sessionNetworkStats[sessionId].push(networkStats);
8417
8454
  }
8418
8455
 
@@ -8437,11 +8474,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8437
8474
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8438
8475
  const ON_CALL_CANCELED = 'onCallCanceled';
8439
8476
  const ON_CALL_FAILED = 'onCallFailed';
8477
+ const ON_CALL_REJECTED = 'onCallRejected';
8440
8478
  const ON_CALL_ENDED = 'onCallEnded';
8441
8479
  const ON_CALL_ENDING = 'onCallEnding';
8442
8480
  const ON_MESSAGE = 'onMessage';
8443
- const ON_REINVITE$1 = 'reinvite';
8444
- const ON_TRACK$1 = 'onTrack';
8481
+ const ON_REINVITE = 'reinvite';
8482
+ const ON_TRACK = 'onTrack';
8445
8483
  const ON_AUDIO_STREAM = 'onAudioStream';
8446
8484
  const ON_VIDEO_STREAM = 'onVideoStream';
8447
8485
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8456,15 +8494,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8456
8494
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8457
8495
  const ON_CALL_ERROR = 'onCallError';
8458
8496
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8459
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
8497
+ const ON_NETWORK_STATS = 'onNetworkStats';
8460
8498
  const ON_CHAT = 'phone/ON_CHAT';
8461
8499
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8462
- const ON_DISCONNECTED$1 = 'onDisconnected';
8500
+ const ON_DISCONNECTED = 'onDisconnected';
8463
8501
 
8464
8502
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8465
8503
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8466
8504
 
8467
- const events$1 = [
8505
+ const events = [
8468
8506
  ON_USER_AGENT,
8469
8507
  ON_REGISTERED,
8470
8508
  ON_UNREGISTERED,
@@ -8481,9 +8519,10 @@ const events$1 = [
8481
8519
  ON_CAMERA_DISABLED,
8482
8520
  ON_CALL_FAILED,
8483
8521
  ON_CALL_ENDED,
8522
+ ON_CALL_REJECTED,
8484
8523
  ON_MESSAGE,
8485
- ON_REINVITE$1,
8486
- ON_TRACK$1,
8524
+ ON_REINVITE,
8525
+ ON_TRACK,
8487
8526
  ON_AUDIO_STREAM,
8488
8527
  ON_VIDEO_STREAM,
8489
8528
  ON_REMOVE_STREAM,
@@ -8498,11 +8537,11 @@ const events$1 = [
8498
8537
  ON_CALL_ERROR,
8499
8538
  ON_CHAT,
8500
8539
  ON_SIGNAL,
8501
- ON_NETWORK_STATS$1,
8502
- ON_DISCONNECTED$1,
8540
+ ON_NETWORK_STATS,
8541
+ ON_DISCONNECTED,
8503
8542
  ];
8504
8543
 
8505
- const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
8544
+ const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
8506
8545
 
8507
8546
  class WebRTCPhone extends Emitter {
8508
8547
 
@@ -8575,7 +8614,7 @@ class WebRTCPhone extends Emitter {
8575
8614
  }).catch(error => {
8576
8615
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8577
8616
  console.error('register error', error, error.message, error.stack);
8578
- logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
8617
+ logger$8.error('WebRTC register error', { message: error.message, stack: error.stack });
8579
8618
  });
8580
8619
  }
8581
8620
 
@@ -8590,7 +8629,7 @@ class WebRTCPhone extends Emitter {
8590
8629
  if (!this.client) {
8591
8630
  return;
8592
8631
  }
8593
- logger$4.info('WebRTC phone stop');
8632
+ logger$8.info('WebRTC phone stop');
8594
8633
  this.client.stop();
8595
8634
  }
8596
8635
 
@@ -8605,11 +8644,12 @@ class WebRTCPhone extends Emitter {
8605
8644
  async sendReinvite(callSession , constraints = null, conference = false,
8606
8645
  audioOnly = false, iceRestart = false) {
8607
8646
  const sipSession = this.findSipSession(callSession);
8608
- logger$4.info('WebRTC phone - send reinvite', {
8647
+ logger$8.info('WebRTC phone - send reinvite', {
8609
8648
  sessionId: sipSession ? sipSession.id : null,
8610
8649
  constraints,
8611
8650
  audioOnly,
8612
8651
  conference,
8652
+ iceRestart,
8613
8653
  });
8614
8654
 
8615
8655
  if (!sipSession) {
@@ -8642,7 +8682,7 @@ class WebRTCPhone extends Emitter {
8642
8682
  }
8643
8683
 
8644
8684
  startHeartbeat() {
8645
- logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8685
+ logger$8.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8646
8686
  if (!this.client || this.client.hasHeartbeat()) {
8647
8687
  return;
8648
8688
  }
@@ -8651,7 +8691,7 @@ class WebRTCPhone extends Emitter {
8651
8691
  }
8652
8692
 
8653
8693
  stopHeartbeat() {
8654
- logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8694
+ logger$8.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8655
8695
  if (!this.client) {
8656
8696
  return;
8657
8697
  }
@@ -8668,7 +8708,7 @@ class WebRTCPhone extends Emitter {
8668
8708
  }
8669
8709
 
8670
8710
  reconnect() {
8671
- logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
8711
+ logger$8.info('WebRTC phone - reconnect', { client: !!this.client });
8672
8712
  if (!this.client) {
8673
8713
  return;
8674
8714
  }
@@ -8709,7 +8749,7 @@ class WebRTCPhone extends Emitter {
8709
8749
  return false;
8710
8750
  }
8711
8751
 
8712
- logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8752
+ logger$8.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8713
8753
 
8714
8754
  this.client.downgradeToAudio(sipSession);
8715
8755
 
@@ -8732,7 +8772,7 @@ class WebRTCPhone extends Emitter {
8732
8772
  return Promise.resolve(false);
8733
8773
  }
8734
8774
 
8735
- logger$4.info('Upgrade to video', {
8775
+ logger$8.info('Upgrade to video', {
8736
8776
  id: callSession ? callSession.getId() : null,
8737
8777
  constraints,
8738
8778
  isConference,
@@ -8772,7 +8812,7 @@ class WebRTCPhone extends Emitter {
8772
8812
 
8773
8813
  _sendReinviteMessage(callSession , isUpgrade ) {
8774
8814
  const sipSession = this.findSipSession(callSession);
8775
- logger$4.info('Sending reinvite message', {
8815
+ logger$8.info('Sending reinvite message', {
8776
8816
  id: callSession ? callSession.getId() : null,
8777
8817
  isUpgrade,
8778
8818
  });
@@ -8798,7 +8838,7 @@ class WebRTCPhone extends Emitter {
8798
8838
  // Monkey patch to know when canceled with the CANCEL message
8799
8839
  const onCancel = sipSession._onCancel.bind(sipSession);
8800
8840
  sipSession._onCancel = (message ) => {
8801
- logger$4.trace('on sip session canceled', { callId: message.callId });
8841
+ logger$8.trace('on sip session canceled', { callId: message.callId });
8802
8842
 
8803
8843
  onCancel(message);
8804
8844
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -8826,16 +8866,17 @@ class WebRTCPhone extends Emitter {
8826
8866
  this.audioOutputVolume,
8827
8867
  );
8828
8868
  case SessionState.Terminating:
8829
- logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8869
+ logger$8.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8830
8870
 
8831
8871
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
8832
8872
 
8833
8873
  break;
8834
8874
  case SessionState.Terminated: {
8835
- logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8875
+ logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8836
8876
 
8837
8877
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8838
8878
  const callSession = this._createCallSession(sipSession);
8879
+ callSession.endTime = new Date();
8839
8880
  const wasCurrentSession = this._onCallTerminated(sipSession);
8840
8881
 
8841
8882
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -8854,7 +8895,7 @@ class WebRTCPhone extends Emitter {
8854
8895
  const [stream] = event.streams;
8855
8896
  const kind = event && event.track && event.track.kind;
8856
8897
 
8857
- logger$4.info('on track stream called on the peer connection', {
8898
+ logger$8.info('on track stream called on the peer connection', {
8858
8899
  callId: this.getSipSessionId(sipSession),
8859
8900
  streamId: stream ? stream.id : null,
8860
8901
  tracks: stream ? stream.getTracks() : null,
@@ -8874,7 +8915,7 @@ class WebRTCPhone extends Emitter {
8874
8915
  };
8875
8916
 
8876
8917
  peerConnection.onremovestream = event => {
8877
- logger$4.info('on remove stream called on the peer connection', {
8918
+ logger$8.info('on remove stream called on the peer connection', {
8878
8919
  id: event.stream.id,
8879
8920
  tracks: event.stream.getTracks(),
8880
8921
  });
@@ -8884,7 +8925,7 @@ class WebRTCPhone extends Emitter {
8884
8925
  }
8885
8926
 
8886
8927
  async startScreenSharing(constraints , callSession ) {
8887
- logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8928
+ logger$8.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8888
8929
 
8889
8930
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
8890
8931
  if (!screenShareStream) {
@@ -8924,7 +8965,7 @@ class WebRTCPhone extends Emitter {
8924
8965
  return;
8925
8966
  }
8926
8967
 
8927
- logger$4.info('WebRTC phone - stop screen sharing', {
8968
+ logger$8.info('WebRTC phone - stop screen sharing', {
8928
8969
  restoreLocalStream,
8929
8970
  });
8930
8971
 
@@ -8980,7 +9021,7 @@ class WebRTCPhone extends Emitter {
8980
9021
  const pc = this.client.getPeerConnection(sipSessionId);
8981
9022
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
8982
9023
 
8983
- logger$4.info('WebRTC phone - on screensharing', {
9024
+ logger$8.info('WebRTC phone - on screensharing', {
8984
9025
  hadVideo,
8985
9026
  id: this.getSipSessionId(sipSession),
8986
9027
  screenTrack,
@@ -8988,7 +9029,7 @@ class WebRTCPhone extends Emitter {
8988
9029
 
8989
9030
  if (screenTrack) {
8990
9031
  screenTrack.onended = () => {
8991
- logger$4.info('WebRTC phone - on screenshare ended', {
9032
+ logger$8.info('WebRTC phone - on screenshare ended', {
8992
9033
  hadVideo,
8993
9034
  id: this.getSipSessionId(sipSession),
8994
9035
  screenTrack,
@@ -9019,7 +9060,7 @@ class WebRTCPhone extends Emitter {
9019
9060
  }
9020
9061
 
9021
9062
  _onCallAccepted(sipSession , cameraEnabled ) {
9022
- logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9063
+ logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9023
9064
 
9024
9065
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9025
9066
  this.currentSipSession = sipSession;
@@ -9037,7 +9078,7 @@ class WebRTCPhone extends Emitter {
9037
9078
  }
9038
9079
 
9039
9080
  changeAudioDevice(id ) {
9040
- logger$4.info('WebRTC phone - change audio device', { deviceId: id });
9081
+ logger$8.info('WebRTC phone - change audio device', { deviceId: id });
9041
9082
  this.audioOutputDeviceId = id;
9042
9083
  this.client.changeAudioOutputDevice(id);
9043
9084
  }
@@ -9047,14 +9088,14 @@ class WebRTCPhone extends Emitter {
9047
9088
  }
9048
9089
 
9049
9090
  changeRingDevice(id ) {
9050
- logger$4.info('WebRTC phone - changing ring device', { id });
9091
+ logger$8.info('WebRTC phone - changing ring device', { id });
9051
9092
 
9052
9093
  this.audioRingDeviceId = id;
9053
9094
  }
9054
9095
 
9055
9096
  // volume is a value between 0 and 1
9056
9097
  changeAudioVolume(volume ) {
9057
- logger$4.info('WebRTC phone - changing audio volume', { volume });
9098
+ logger$8.info('WebRTC phone - changing audio volume', { volume });
9058
9099
 
9059
9100
  this.audioOutputVolume = volume;
9060
9101
  this.client.changeAudioOutputVolume(volume);
@@ -9062,32 +9103,33 @@ class WebRTCPhone extends Emitter {
9062
9103
 
9063
9104
  // volume is a value between 0 and 1
9064
9105
  changeRingVolume(volume ) {
9065
- logger$4.info('WebRTC phone - changing ring volume', { volume });
9106
+ logger$8.info('WebRTC phone - changing ring volume', { volume });
9066
9107
 
9067
9108
  this.audioRingVolume = volume;
9068
9109
  }
9069
9110
 
9070
9111
  changeAudioInputDevice(id ) {
9071
- logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
9112
+ logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9072
9113
 
9073
9114
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9074
9115
  }
9075
9116
 
9076
9117
  changeVideoInputDevice(id ) {
9077
- logger$4.info('WebRTC phone - change video input device', { deviceId: id });
9118
+ logger$8.info('WebRTC phone - change video input device', { deviceId: id });
9078
9119
 
9079
9120
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9080
9121
  }
9081
9122
 
9082
9123
  changeSessionVideoInputDevice(id ) {
9083
- logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
9124
+ logger$8.info('WebRTC phone - change session video input device', { deviceId: id });
9084
9125
 
9085
9126
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9086
9127
  }
9087
9128
 
9088
9129
  _onCallTerminated(sipSession ) {
9089
- logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9130
+ logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9090
9131
 
9132
+ const sipSessionId = this.getSipSessionId(sipSession);
9091
9133
  const callSession = this._createCallSession(sipSession);
9092
9134
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9093
9135
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9105,7 +9147,6 @@ class WebRTCPhone extends Emitter {
9105
9147
  }, 5);
9106
9148
  }
9107
9149
 
9108
- const sipSessionId = this.getSipSessionId(sipSession);
9109
9150
  if (sipSessionId) {
9110
9151
  this.removeIncomingSessions(sipSessionId);
9111
9152
  }
@@ -9120,7 +9161,7 @@ class WebRTCPhone extends Emitter {
9120
9161
  const hasIncomingCallSession = this.hasIncomingCallSession();
9121
9162
 
9122
9163
  // Re-trigger incoming call event for remaining incoming calls
9123
- logger$4.info('WebRTC phone - check to re-trigger incoming call', {
9164
+ logger$8.info('WebRTC phone - check to re-trigger incoming call', {
9124
9165
  sipId: sipSession.id,
9125
9166
  shouldRetrigger,
9126
9167
  hasIncomingCallSession,
@@ -9211,37 +9252,37 @@ class WebRTCPhone extends Emitter {
9211
9252
 
9212
9253
  // Deprecated
9213
9254
  getLocalStreamForCall(callSession ) {
9214
- logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9255
+ logger$8.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9215
9256
 
9216
9257
  return this.getLocalStream(callSession);
9217
9258
  }
9218
9259
 
9219
9260
  // Deprecated
9220
9261
  getRemoteStreamForCall(callSession ) {
9221
- logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9262
+ logger$8.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9222
9263
 
9223
9264
  return this.getRemoteVideoStream(callSession);
9224
9265
  }
9225
9266
 
9226
9267
  getRemoteStreamsForCall(callSession ) {
9227
- logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9268
+ logger$8.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9228
9269
 
9229
9270
  return this.getRemoteStream(callSession);
9230
9271
  }
9231
9272
 
9232
9273
  accept(callSession , cameraEnabled ) {
9233
- logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9274
+ logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9234
9275
  if (this.currentSipSession) {
9235
9276
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9236
9277
  }
9237
9278
 
9238
9279
  if (!callSession) {
9239
- logger$4.warn('no CallSession to accept.');
9280
+ logger$8.warn('no CallSession to accept.');
9240
9281
  return Promise.resolve(null);
9241
9282
  }
9242
9283
 
9243
9284
  if (callSession.getId() in this.acceptedSessions) {
9244
- logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9285
+ logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9245
9286
  return Promise.resolve(callSession.sipCallId);
9246
9287
  }
9247
9288
 
@@ -9253,24 +9294,24 @@ class WebRTCPhone extends Emitter {
9253
9294
  const sipSession = this.client.getSipSession(callSession.getId());
9254
9295
  if (sipSession) {
9255
9296
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
9256
- logger$4.warn('Trying to answer a terminated sipSession.');
9297
+ logger$8.warn('Trying to answer a terminated sipSession.');
9257
9298
 
9258
9299
  return Promise.resolve(null);
9259
9300
  }
9260
9301
 
9261
- logger$4.info('accept call, session found', { sipId: sipSession.id });
9302
+ logger$8.info('accept call, session found', { sipId: sipSession.id });
9262
9303
 
9263
9304
  // $FlowFixMe
9264
9305
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9265
9306
  return callSession.sipCallId;
9266
9307
  }).catch(e => {
9267
- logger$4.error(e);
9308
+ logger$8.error(e);
9268
9309
  this.endCurrentCall(callSession);
9269
9310
  throw e;
9270
9311
  });
9271
9312
  }
9272
9313
 
9273
- logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9314
+ logger$8.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9274
9315
 
9275
9316
  return Promise.resolve(null);
9276
9317
  }
@@ -9280,7 +9321,7 @@ class WebRTCPhone extends Emitter {
9280
9321
  }
9281
9322
 
9282
9323
  async reject(callSession ) {
9283
- logger$4.info('reject WebRTC called', { id: callSession.getId() });
9324
+ logger$8.info('reject WebRTC called', { id: callSession.getId() });
9284
9325
 
9285
9326
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9286
9327
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9292,14 +9333,14 @@ class WebRTCPhone extends Emitter {
9292
9333
 
9293
9334
  const sipSession = this.findSipSession(callSession);
9294
9335
  if (sipSession) {
9295
- logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
9336
+ logger$8.info('WebRTC rejecting', { sipId: sipSession.id });
9296
9337
 
9297
9338
  this.client.hangup(sipSession);
9298
9339
  }
9299
9340
  }
9300
9341
 
9301
9342
  async ignore(callSession ) {
9302
- logger$4.info('WebRTC ignore', { id: callSession.getId() });
9343
+ logger$8.info('WebRTC ignore', { id: callSession.getId() });
9303
9344
 
9304
9345
  // kill the ring
9305
9346
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9311,14 +9352,14 @@ class WebRTCPhone extends Emitter {
9311
9352
  const sipSession = this.findSipSession(callSession);
9312
9353
 
9313
9354
  if (sipSession) {
9314
- logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
9355
+ logger$8.info('WebRTC atxfer', { sipId: sipSession.id });
9315
9356
 
9316
9357
  return this.client.atxfer(sipSession);
9317
9358
  }
9318
9359
  }
9319
9360
 
9320
9361
  hold(callSession , withEvent = true, isConference = false) {
9321
- logger$4.info('WebRTC hold', { id: callSession.getId() });
9362
+ logger$8.info('WebRTC hold', { id: callSession.getId() });
9322
9363
 
9323
9364
  const sipSession = this.findSipSession(callSession);
9324
9365
 
@@ -9333,18 +9374,18 @@ class WebRTCPhone extends Emitter {
9333
9374
  }
9334
9375
 
9335
9376
  resume(callSession , isConference = false, withEvent = true) {
9336
- logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9377
+ logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9337
9378
 
9338
9379
  const sipSession = this.findSipSession(callSession);
9339
9380
  if (!sipSession) {
9340
9381
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9341
9382
  }
9342
9383
 
9343
- logger$4.info('WebRTC resuming', { sipId: sipSession.id });
9384
+ logger$8.info('WebRTC resuming', { sipId: sipSession.id });
9344
9385
 
9345
9386
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9346
9387
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9347
- logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9388
+ logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9348
9389
  this.holdSipSession(this.currentSipSession, callSession);
9349
9390
  }
9350
9391
 
@@ -9369,7 +9410,7 @@ class WebRTCPhone extends Emitter {
9369
9410
  const sessionId = this.getSipSessionId(sipSession);
9370
9411
  const hasVideo = this.client.hasLocalVideo(sessionId);
9371
9412
 
9372
- logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9413
+ logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9373
9414
 
9374
9415
  // Stop screenshre if needed
9375
9416
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9400,7 +9441,7 @@ class WebRTCPhone extends Emitter {
9400
9441
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9401
9442
  }
9402
9443
  const sessionId = this.getSipSessionId(sipSession);
9403
- logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
9444
+ logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9404
9445
 
9405
9446
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9406
9447
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9444,14 +9485,14 @@ class WebRTCPhone extends Emitter {
9444
9485
  }
9445
9486
 
9446
9487
  mute(callSession , withEvent = true) {
9447
- logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9488
+ logger$8.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9448
9489
 
9449
9490
  const sipSession = this.findSipSession(callSession);
9450
9491
  if (!sipSession) {
9451
9492
  return;
9452
9493
  }
9453
9494
 
9454
- logger$4.info('WebRTC muting', { sipId: sipSession.id });
9495
+ logger$8.info('WebRTC muting', { sipId: sipSession.id });
9455
9496
  this.client.mute(sipSession);
9456
9497
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9457
9498
 
@@ -9465,14 +9506,14 @@ class WebRTCPhone extends Emitter {
9465
9506
  }
9466
9507
 
9467
9508
  unmute(callSession , withEvent = true) {
9468
- logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9509
+ logger$8.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9469
9510
 
9470
9511
  const sipSession = this.findSipSession(callSession);
9471
9512
  if (!sipSession) {
9472
9513
  return;
9473
9514
  }
9474
9515
 
9475
- logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
9516
+ logger$8.info('WebRTC unmuting', { sipId: sipSession.id });
9476
9517
  this.client.unmute(sipSession);
9477
9518
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9478
9519
 
@@ -9499,7 +9540,7 @@ class WebRTCPhone extends Emitter {
9499
9540
  if (!sipSession) {
9500
9541
  return;
9501
9542
  }
9502
- logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
9543
+ logger$8.info('WebRTC turn camera on', { sipId: sipSession.id });
9503
9544
 
9504
9545
  this.client.toggleCameraOn(sipSession);
9505
9546
 
@@ -9511,7 +9552,7 @@ class WebRTCPhone extends Emitter {
9511
9552
  if (!sipSession) {
9512
9553
  return;
9513
9554
  }
9514
- logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
9555
+ logger$8.info('WebRTC turn camera off', { sipId: sipSession.id });
9515
9556
 
9516
9557
  this.client.toggleCameraOff(sipSession);
9517
9558
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9523,7 +9564,7 @@ class WebRTCPhone extends Emitter {
9523
9564
  return;
9524
9565
  }
9525
9566
 
9526
- logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
9567
+ logger$8.info('WebRTC send key', { sipId: sipSession.id, tone });
9527
9568
  this.client.sendDTMF(sipSession, tone);
9528
9569
  }
9529
9570
 
@@ -9531,7 +9572,7 @@ class WebRTCPhone extends Emitter {
9531
9572
  // @TODO: line is not used here
9532
9573
  async makeCall(number , line , cameraEnabled ,
9533
9574
  audioOnly = false, conference = false) {
9534
- logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9575
+ logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
9535
9576
  if (!number) {
9536
9577
  return Promise.resolve(null);
9537
9578
  }
@@ -9541,7 +9582,7 @@ class WebRTCPhone extends Emitter {
9541
9582
  }
9542
9583
  if (this.currentSipSession) {
9543
9584
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9544
- logger$4.warn('Unable to hold current session when making another call', e);
9585
+ logger$8.warn('Unable to hold current session when making another call', e);
9545
9586
  });
9546
9587
  }
9547
9588
 
@@ -9551,10 +9592,11 @@ class WebRTCPhone extends Emitter {
9551
9592
  this._bindEvents(sipSession);
9552
9593
  } catch (error) {
9553
9594
  console.warn(error);
9554
- logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9595
+ logger$8.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9555
9596
  return Promise.resolve(null);
9556
9597
  }
9557
9598
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9599
+ callSession.creationTime = new Date();
9558
9600
 
9559
9601
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9560
9602
 
@@ -9579,7 +9621,7 @@ class WebRTCPhone extends Emitter {
9579
9621
  return;
9580
9622
  }
9581
9623
 
9582
- logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
9624
+ logger$8.info('WebRTC transfer', { sipId: sipSession.id, target });
9583
9625
 
9584
9626
  this.client.transfer(sipSession, target);
9585
9627
  }
@@ -9588,7 +9630,7 @@ class WebRTCPhone extends Emitter {
9588
9630
  const sipSession = this.client.getSipSession(source.sipCallId);
9589
9631
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9590
9632
 
9591
- logger$4.info('WebRTC indirect transfer', {
9633
+ logger$8.info('WebRTC indirect transfer', {
9592
9634
  sipId: sipSession ? sipSession.id : null,
9593
9635
  target: sipSessionTarget ? sipSessionTarget.id : null,
9594
9636
  });
@@ -9627,7 +9669,7 @@ class WebRTCPhone extends Emitter {
9627
9669
  return false;
9628
9670
  }
9629
9671
 
9630
- logger$4.info('WebRTC hangup', { sipId: sipSession.id });
9672
+ logger$8.info('WebRTC hangup', { sipId: sipSession.id });
9631
9673
 
9632
9674
  const sipSessionId = this.getSipSessionId(sipSession);
9633
9675
 
@@ -9673,7 +9715,7 @@ class WebRTCPhone extends Emitter {
9673
9715
  endCurrentCall(callSession ) {
9674
9716
  const isCurrent = this.isCurrentCallSipSession(callSession);
9675
9717
 
9676
- logger$4.info('Ending current call', {
9718
+ logger$8.info('Ending current call', {
9677
9719
  id: callSession ? callSession.getId() : null,
9678
9720
  isCurrent,
9679
9721
  });
@@ -9697,7 +9739,7 @@ class WebRTCPhone extends Emitter {
9697
9739
  }
9698
9740
 
9699
9741
  async close() {
9700
- logger$4.info('WebRTC close');
9742
+ logger$8.info('WebRTC close');
9701
9743
 
9702
9744
  try {
9703
9745
  await Promise.race([
@@ -9705,7 +9747,7 @@ class WebRTCPhone extends Emitter {
9705
9747
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9706
9748
  ]);
9707
9749
  } catch (e) {
9708
- logger$4.error('WebRTC close, unregister error', e);
9750
+ logger$8.error('WebRTC close, unregister error', e);
9709
9751
  }
9710
9752
 
9711
9753
  this.client.close();
@@ -9723,12 +9765,12 @@ class WebRTCPhone extends Emitter {
9723
9765
  }
9724
9766
 
9725
9767
  enableRinging() {
9726
- logger$4.info('WebRTC enable ringing');
9768
+ logger$8.info('WebRTC enable ringing');
9727
9769
  this.ringingEnabled = true;
9728
9770
  }
9729
9771
 
9730
9772
  disableRinging() {
9731
- logger$4.info('WebRTC disable ringing');
9773
+ logger$8.info('WebRTC disable ringing');
9732
9774
  this.ringingEnabled = false;
9733
9775
  }
9734
9776
 
@@ -9750,8 +9792,12 @@ class WebRTCPhone extends Emitter {
9750
9792
  }
9751
9793
 
9752
9794
  const sessionId = this.incomingSessions[0];
9795
+ const sipSession = this.client.getSipSession(sessionId);
9796
+ if (!sipSession) {
9797
+ return null;
9798
+ }
9753
9799
 
9754
- return this._createCallSession(this.client.getSipSession(sessionId));
9800
+ return this._createCallSession(sipSession);
9755
9801
  }
9756
9802
 
9757
9803
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -9768,7 +9814,7 @@ class WebRTCPhone extends Emitter {
9768
9814
 
9769
9815
  // Deprecated
9770
9816
  getLocalMediaStream(callSession ) {
9771
- logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9817
+ logger$8.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9772
9818
  return this.getLocalStream(callSession);
9773
9819
  }
9774
9820
 
@@ -9810,7 +9856,7 @@ class WebRTCPhone extends Emitter {
9810
9856
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
9811
9857
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
9812
9858
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
9813
- logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9859
+ logger$8.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9814
9860
 
9815
9861
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
9816
9862
  this.incomingSessions.push(callSession.getId());
@@ -9829,11 +9875,12 @@ class WebRTCPhone extends Emitter {
9829
9875
  callSession);
9830
9876
  }
9831
9877
 
9878
+ callSession.creationTime = new Date();
9832
9879
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9833
9880
  });
9834
9881
 
9835
9882
  this.client.on(this.client.ON_REINVITE, (...args) => {
9836
- logger$4.info('WebRTC on reinvite', {
9883
+ logger$8.info('WebRTC on reinvite', {
9837
9884
  sessionId: args[0].id,
9838
9885
  inviteId: args[1].id,
9839
9886
  updatedCalleeName: args[2],
@@ -9853,7 +9900,7 @@ class WebRTCPhone extends Emitter {
9853
9900
  });
9854
9901
 
9855
9902
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9856
- logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
9903
+ logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9857
9904
 
9858
9905
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
9859
9906
 
@@ -9864,22 +9911,29 @@ class WebRTCPhone extends Emitter {
9864
9911
  this.client.on('ended', () => {});
9865
9912
 
9866
9913
  this.client.on(this.client.ON_ERROR, e => {
9867
- logger$4.error('WebRTC error', e);
9914
+ logger$8.error('WebRTC error', e);
9868
9915
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9869
9916
  });
9870
9917
 
9918
+ this.client.on(this.client.REJECTED, session => {
9919
+ logger$8.info('WebRTC call rejected', session.id);
9920
+ const callSession = this._createCallSession(session);
9921
+ callSession.endTime = new Date();
9922
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9923
+ });
9924
+
9871
9925
  this.client.on(this.client.UNREGISTERED, () => {
9872
- logger$4.info('WebRTC unregistered');
9926
+ logger$8.info('WebRTC unregistered');
9873
9927
  this.eventEmitter.emit(ON_UNREGISTERED);
9874
9928
  });
9875
9929
 
9876
9930
  this.client.on(this.client.ON_DISCONNECTED, () => {
9877
- logger$4.info('WebRTC disconnected');
9878
- this.eventEmitter.emit(ON_DISCONNECTED$1);
9931
+ logger$8.info('WebRTC disconnected');
9932
+ this.eventEmitter.emit(ON_DISCONNECTED);
9879
9933
  });
9880
9934
 
9881
9935
  this.client.on(this.client.REGISTERED, () => {
9882
- logger$4.info('WebRTC registered', {
9936
+ logger$8.info('WebRTC registered', {
9883
9937
  shouldSendReinvite: this.shouldSendReinvite,
9884
9938
  state: this.currentSipSession ? this.currentSipSession.state : null,
9885
9939
  currentSipSession: !!this.currentSipSession,
@@ -9900,19 +9954,19 @@ class WebRTCPhone extends Emitter {
9900
9954
  // Send reinvite with iceRestart
9901
9955
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
9902
9956
  } catch (e) {
9903
- logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9957
+ logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9904
9958
  }
9905
9959
  }
9906
9960
  });
9907
9961
 
9908
9962
  this.client.on(this.client.CONNECTED, () => {
9909
- logger$4.info('WebRTC client connected');
9963
+ logger$8.info('WebRTC client connected');
9910
9964
 
9911
9965
  this.stopHeartbeat();
9912
9966
  });
9913
9967
 
9914
9968
  this.client.on(this.client.DISCONNECTED, () => {
9915
- logger$4.info('WebRTC client disconnected');
9969
+ logger$8.info('WebRTC client disconnected');
9916
9970
 
9917
9971
  this.eventEmitter.emit(ON_UNREGISTERED);
9918
9972
 
@@ -9926,7 +9980,7 @@ class WebRTCPhone extends Emitter {
9926
9980
  });
9927
9981
 
9928
9982
  this.client.on(this.client.ON_TRACK, (session, event) => {
9929
- this.eventEmitter.emit(ON_TRACK$1, session, event);
9983
+ this.eventEmitter.emit(ON_TRACK, session, event);
9930
9984
  });
9931
9985
 
9932
9986
  this.client.on('onVideoInputChange', stream => {
@@ -9941,7 +9995,7 @@ class WebRTCPhone extends Emitter {
9941
9995
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
9942
9996
  const callSession = this.getCallSession(this.getSipSessionId(session));
9943
9997
 
9944
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
9998
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
9945
9999
  });
9946
10000
 
9947
10001
  // Used when upgrading directly in screenshare mode
@@ -9950,7 +10004,7 @@ class WebRTCPhone extends Emitter {
9950
10004
  const localStream = this.client.getLocalStream(sipSessionId);
9951
10005
  const callSession = this.callSessions[sipSessionId];
9952
10006
 
9953
- logger$4.info('Updrading directly in screensharing mode', {
10007
+ logger$8.info('Updrading directly in screensharing mode', {
9954
10008
  sipSessionId,
9955
10009
  tracks: localStream ? localStream.getTracks() : null,
9956
10010
  });
@@ -10080,6 +10134,7 @@ class WebRTCPhone extends Emitter {
10080
10134
  const number = identity ? identity.uri._normal.user : null;
10081
10135
  const { state } = sipSession || {};
10082
10136
  const sessionId = this.getSipSessionId(sipSession);
10137
+ fromSession = fromSession || this.callSessions[sessionId];
10083
10138
 
10084
10139
  const callSession = new CallSession({
10085
10140
  callId: fromSession && fromSession.callId,
@@ -10087,6 +10142,8 @@ class WebRTCPhone extends Emitter {
10087
10142
  sipStatus: state,
10088
10143
  displayName: identity ? identity.displayName || number : number,
10089
10144
  startTime: fromSession ? fromSession.startTime : new Date(),
10145
+ creationTime: fromSession ? fromSession.creationTime : null,
10146
+ endTime: fromSession ? fromSession.endTime : null,
10090
10147
  answered: state === SessionState.Established,
10091
10148
  paused: this.client.isCallHeld(sipSession),
10092
10149
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10097,6 +10154,7 @@ class WebRTCPhone extends Emitter {
10097
10154
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10098
10155
  recording: fromSession ? fromSession.isRecording() : false,
10099
10156
  recordingPaused: false, // @TODO
10157
+ sipSession,
10100
10158
  ...extra,
10101
10159
  });
10102
10160
 
@@ -10125,11 +10183,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10125
10183
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10126
10184
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10127
10185
  ON_CALL_FAILED: ON_CALL_FAILED,
10186
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10128
10187
  ON_CALL_ENDED: ON_CALL_ENDED,
10129
10188
  ON_CALL_ENDING: ON_CALL_ENDING,
10130
10189
  ON_MESSAGE: ON_MESSAGE,
10131
- ON_REINVITE: ON_REINVITE$1,
10132
- ON_TRACK: ON_TRACK$1,
10190
+ ON_REINVITE: ON_REINVITE,
10191
+ ON_TRACK: ON_TRACK,
10133
10192
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10134
10193
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10135
10194
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10144,13 +10203,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10144
10203
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10145
10204
  ON_CALL_ERROR: ON_CALL_ERROR,
10146
10205
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10147
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10206
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10148
10207
  ON_CHAT: ON_CHAT,
10149
10208
  ON_SIGNAL: ON_SIGNAL,
10150
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10209
+ ON_DISCONNECTED: ON_DISCONNECTED,
10151
10210
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10152
10211
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10153
- events: events$1,
10212
+ events: events,
10154
10213
  'default': WebRTCPhone
10155
10214
  });
10156
10215
 
@@ -10159,7 +10218,7 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10159
10218
  class InvalidSubscription extends Error {}
10160
10219
  class InvalidAuthorization extends Error {}
10161
10220
 
10162
- const logger$5 = IssueReporter$1.loggerFor('simple-auth');
10221
+ const logger$7 = IssueReporter$1.loggerFor('simple-auth');
10163
10222
 
10164
10223
  class Auth {
10165
10224
 
@@ -10194,7 +10253,7 @@ class Auth {
10194
10253
  setApiClientId(this.clientId);
10195
10254
  setRefreshExpiration(this.expiration);
10196
10255
  setOnRefreshToken((token , session ) => {
10197
- logger$5.info('on refresh token done', { token });
10256
+ logger$7.info('on refresh token done', { token });
10198
10257
  setApiToken(token);
10199
10258
  Wazo.Websocket.updateToken(token);
10200
10259
 
@@ -10239,7 +10298,7 @@ class Auth {
10239
10298
  const rawSession = await getApiClient().auth.authenticate(token);
10240
10299
  return this._onAuthenticated(rawSession);
10241
10300
  } catch (e) {
10242
- logger$5.error('on validate token error', e);
10301
+ logger$7.error('on validate token error', e);
10243
10302
  console.warn(e);
10244
10303
  return false;
10245
10304
  }
@@ -10420,7 +10479,7 @@ var Auth$1 = global.wazoAuthInstance;
10420
10479
 
10421
10480
  //
10422
10481
 
10423
- const SOCKET_EVENTS = {
10482
+ const SOCKET_EVENTS$1 = {
10424
10483
  ON_OPEN: 'onopen',
10425
10484
  ON_MESSAGE: 'onmessage',
10426
10485
  ON_ERROR: 'onerror',
@@ -10573,16 +10632,16 @@ class WebSocketClient extends Emitter {
10573
10632
 
10574
10633
  this.socket.onopen = () => {
10575
10634
  logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
10576
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10635
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10577
10636
  };
10578
10637
 
10579
10638
  this.socket.onerror = event => {
10580
10639
  logger$6.error('on Wazo WS error', event.target);
10581
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10640
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10582
10641
  };
10583
10642
 
10584
10643
  this.socket.onmessage = (event ) => {
10585
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10644
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
10586
10645
 
10587
10646
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10588
10647
  let { name } = message;
@@ -10615,11 +10674,11 @@ class WebSocketClient extends Emitter {
10615
10674
  token: this.token,
10616
10675
  });
10617
10676
  this.initialized = false;
10618
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10677
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
10619
10678
 
10620
10679
  switch (event.code) {
10621
10680
  case 4002:
10622
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10681
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
10623
10682
  break;
10624
10683
  }
10625
10684
  };
@@ -10735,7 +10794,7 @@ class WebSocketClient extends Emitter {
10735
10794
  break;
10736
10795
  case 'start':
10737
10796
  this.initialized = true;
10738
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
10797
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
10739
10798
  break;
10740
10799
  default:
10741
10800
  this.eventEmitter.emit('message', message);
@@ -10782,7 +10841,7 @@ class WebSocketClient extends Emitter {
10782
10841
  logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
10783
10842
 
10784
10843
  this.close();
10785
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
10844
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
10786
10845
 
10787
10846
  if (this.onHeartBeatTimeout) {
10788
10847
  this.onHeartBeatTimeout();
@@ -10862,7 +10921,7 @@ WebSocketClient.eventLists = [
10862
10921
 
10863
10922
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10864
10923
  __proto__: null,
10865
- SOCKET_EVENTS: SOCKET_EVENTS,
10924
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
10866
10925
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
10867
10926
  FAVORITE_ADDED: FAVORITE_ADDED,
10868
10927
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -10935,10 +10994,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
10935
10994
 
10936
10995
  //
10937
10996
 
10938
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
10939
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
10997
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
10998
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
10940
10999
 
10941
- const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
11000
+ const logger$5 = IssueReporter$1.loggerFor('simple-ws-client');
10942
11001
 
10943
11002
  class Websocket extends Emitter {
10944
11003
 
@@ -10952,9 +11011,9 @@ class Websocket extends Emitter {
10952
11011
  // $FlowFixMe
10953
11012
  this[key] = OTHER_EVENTS[key];
10954
11013
  });
10955
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
11014
+ Object.keys(SOCKET_EVENTS).forEach(key => {
10956
11015
  // $FlowFixMe
10957
- this[key] = SOCKET_EVENTS$1[key];
11016
+ this[key] = SOCKET_EVENTS[key];
10958
11017
  });
10959
11018
  this.eventLists = WebSocketClient.eventLists;
10960
11019
 
@@ -10962,7 +11021,7 @@ class Websocket extends Emitter {
10962
11021
  }
10963
11022
 
10964
11023
  open(host , session ) {
10965
- logger$7.info('open simple WebSocket', { host, token: session.token });
11024
+ logger$5.info('open simple WebSocket', { host, token: session.token });
10966
11025
  this.ws = new WebSocketClient(
10967
11026
  {
10968
11027
  host,
@@ -10990,7 +11049,7 @@ class Websocket extends Emitter {
10990
11049
  }
10991
11050
 
10992
11051
  updateToken(token ) {
10993
- logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
11052
+ logger$5.info('update token via simple Websocket', { token, ws: !!this.ws });
10994
11053
 
10995
11054
  if (!this.ws) {
10996
11055
  return;
@@ -11018,7 +11077,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11018
11077
 
11019
11078
  //
11020
11079
 
11021
- const logger$8 = IssueReporter$1.loggerFor('room');
11080
+ const logger$4 = IssueReporter$1.loggerFor('room');
11022
11081
 
11023
11082
  class Participant extends Emitter {
11024
11083
 
@@ -11140,7 +11199,7 @@ class Participant extends Emitter {
11140
11199
  }
11141
11200
 
11142
11201
  onTalking(isTalking ) {
11143
- logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11202
+ logger$4.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11144
11203
  this.isTalking = isTalking;
11145
11204
  // you may notice we're not broadcasting: since all participants are getting this info
11146
11205
  // directly from asterisk, there's no need to do so
@@ -11243,7 +11302,7 @@ class Participant extends Emitter {
11243
11302
  }
11244
11303
 
11245
11304
  updateStatus(status , broadcast = true) {
11246
- logger$8.info('updating participant status', { name: this.name, status });
11305
+ logger$4.info('updating participant status', { name: this.name, status });
11247
11306
 
11248
11307
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11249
11308
  if (status.audioMuted) {
@@ -11291,7 +11350,7 @@ class Participant extends Emitter {
11291
11350
 
11292
11351
  broadcastStatus(inboundStatus = null) {
11293
11352
  const status = inboundStatus || this.getStatus();
11294
- logger$8.info('broadcasting participant status', { callId: this.callId, status });
11353
+ logger$4.info('broadcasting participant status', { callId: this.callId, status });
11295
11354
 
11296
11355
  this.room.sendSignal({
11297
11356
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11327,9 +11386,9 @@ class LocalParticipant extends Participant {
11327
11386
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11328
11387
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11329
11388
 
11330
- const logger$9 = IssueReporter$1.loggerFor('sdk-room');
11389
+ const logger$3 = IssueReporter$1.loggerFor('sdk-room');
11331
11390
 
11332
- class Room extends Emitter {
11391
+ class Room$1 extends Emitter {
11333
11392
 
11334
11393
 
11335
11394
 
@@ -11387,7 +11446,7 @@ class Room extends Emitter {
11387
11446
  extra = {},
11388
11447
  ) {
11389
11448
  super();
11390
- logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
11449
+ logger$3.info('room initialized', { callId, extension, sourceId, meetingUuid });
11391
11450
 
11392
11451
  // Represents the room callSession
11393
11452
  this.callSession = callSession;
@@ -11453,7 +11512,7 @@ class Room extends Emitter {
11453
11512
  * @returns {Promise<Room>}
11454
11513
  */
11455
11514
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11456
- logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
11515
+ logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11457
11516
 
11458
11517
  if (!room) {
11459
11518
  await Wazo.Phone.connect();
@@ -11466,7 +11525,7 @@ class Room extends Emitter {
11466
11525
 
11467
11526
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11468
11527
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11469
- logger$9.info('room call received via WS', { callId: data.call_id });
11528
+ logger$3.info('room call received via WS', { callId: data.call_id });
11470
11529
  if (room) {
11471
11530
  room.setCallId(data.call_id);
11472
11531
  }
@@ -11474,7 +11533,7 @@ class Room extends Emitter {
11474
11533
 
11475
11534
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11476
11535
  // eslint-disable-next-line no-param-reassign
11477
- room = new Room(callSession, extension, null, null, extra);
11536
+ room = new Room$1(callSession, extension, null, null, extra);
11478
11537
 
11479
11538
  // Wait for the call to be accepted
11480
11539
  await new Promise((resolve, reject) => {
@@ -11495,7 +11554,7 @@ class Room extends Emitter {
11495
11554
  // Retrieve conference
11496
11555
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11497
11556
 
11498
- logger$9.info('connected to room', {
11557
+ logger$3.info('connected to room', {
11499
11558
  sourceId: conference ? conference.sourceId : null,
11500
11559
  name: conference ? conference.name : null,
11501
11560
  });
@@ -11505,7 +11564,7 @@ class Room extends Emitter {
11505
11564
  room.setName(conference.name);
11506
11565
  }
11507
11566
  } else if (meeting) {
11508
- logger$9.info('Already connected to meeting', {
11567
+ logger$3.info('Already connected to meeting', {
11509
11568
  uuid: meeting.uuid,
11510
11569
  name: meeting.name,
11511
11570
  });
@@ -11518,13 +11577,13 @@ class Room extends Emitter {
11518
11577
  }
11519
11578
 
11520
11579
  static disconnect() {
11521
- logger$9.info('static disconnection to room');
11580
+ logger$3.info('static disconnection to room');
11522
11581
 
11523
11582
  Wazo.Phone.disconnect();
11524
11583
  }
11525
11584
 
11526
11585
  async disconnect() {
11527
- logger$9.info('disconnection to room called');
11586
+ logger$3.info('disconnection to room called');
11528
11587
 
11529
11588
  await Wazo.Phone.hangup(this.callSession);
11530
11589
  this.callSession = null;
@@ -11544,19 +11603,19 @@ class Room extends Emitter {
11544
11603
  }
11545
11604
 
11546
11605
  setSourceId(sourceId ) {
11547
- logger$9.info('set room source id', { sourceId });
11606
+ logger$3.info('set room source id', { sourceId });
11548
11607
 
11549
11608
  this.sourceId = sourceId;
11550
11609
  }
11551
11610
 
11552
11611
  setMeetingUuid(meetingUuid ) {
11553
- logger$9.info('set meeting uuid', { meetingUuid });
11612
+ logger$3.info('set meeting uuid', { meetingUuid });
11554
11613
 
11555
11614
  this.meetingUuid = meetingUuid;
11556
11615
  }
11557
11616
 
11558
11617
  setCallId(callId ) {
11559
- logger$9.info('set room call id', { callId });
11618
+ logger$3.info('set room call id', { callId });
11560
11619
 
11561
11620
  if (callId) {
11562
11621
  this.callId = callId;
@@ -11564,7 +11623,7 @@ class Room extends Emitter {
11564
11623
  }
11565
11624
 
11566
11625
  setName(name ) {
11567
- logger$9.info('set room name', { name });
11626
+ logger$3.info('set room name', { name });
11568
11627
 
11569
11628
  this.name = name;
11570
11629
  }
@@ -11583,7 +11642,7 @@ class Room extends Emitter {
11583
11642
  }
11584
11643
 
11585
11644
  async startScreenSharing(constraints ) {
11586
- logger$9.info('start room screen sharing', { constraints });
11645
+ logger$3.info('start room screen sharing', { constraints });
11587
11646
 
11588
11647
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11589
11648
  if (!screensharingStream) {
@@ -11597,7 +11656,7 @@ class Room extends Emitter {
11597
11656
  }
11598
11657
 
11599
11658
  async stopScreenSharing(restoreLocalStream = true) {
11600
- logger$9.info('stop room screen sharing');
11659
+ logger$3.info('stop room screen sharing');
11601
11660
 
11602
11661
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11603
11662
 
@@ -11609,7 +11668,7 @@ class Room extends Emitter {
11609
11668
  }
11610
11669
 
11611
11670
  turnCameraOff() {
11612
- logger$9.info('turn room camera off');
11671
+ logger$3.info('turn room camera off');
11613
11672
 
11614
11673
  Wazo.Phone.turnCameraOff(this.callSession);
11615
11674
 
@@ -11619,7 +11678,7 @@ class Room extends Emitter {
11619
11678
  }
11620
11679
 
11621
11680
  turnCameraOn() {
11622
- logger$9.info('turn room camera on');
11681
+ logger$3.info('turn room camera on');
11623
11682
 
11624
11683
  Wazo.Phone.turnCameraOn(this.callSession);
11625
11684
 
@@ -11629,7 +11688,7 @@ class Room extends Emitter {
11629
11688
  }
11630
11689
 
11631
11690
  mute() {
11632
- logger$9.info('mute room');
11691
+ logger$3.info('mute room');
11633
11692
 
11634
11693
  Wazo.Phone.mute(this.callSession);
11635
11694
 
@@ -11637,7 +11696,7 @@ class Room extends Emitter {
11637
11696
  }
11638
11697
 
11639
11698
  unmute() {
11640
- logger$9.info('unmute room');
11699
+ logger$3.info('unmute room');
11641
11700
 
11642
11701
  Wazo.Phone.unmute(this.callSession);
11643
11702
 
@@ -11657,7 +11716,7 @@ class Room extends Emitter {
11657
11716
  }
11658
11717
 
11659
11718
  hold() {
11660
- logger$9.info('hold room');
11719
+ logger$3.info('hold room');
11661
11720
 
11662
11721
  Wazo.Phone.hold(this.callSession, true);
11663
11722
 
@@ -11667,7 +11726,7 @@ class Room extends Emitter {
11667
11726
  }
11668
11727
 
11669
11728
  async resume() {
11670
- logger$9.info('resume room');
11729
+ logger$3.info('resume room');
11671
11730
 
11672
11731
  const newStream = await Wazo.Phone.resume(this.callSession, true);
11673
11732
 
@@ -11695,13 +11754,13 @@ class Room extends Emitter {
11695
11754
  }
11696
11755
 
11697
11756
  sendDTMF(tone ) {
11698
- logger$9.info('send room DTMF', { tone });
11757
+ logger$3.info('send room DTMF', { tone });
11699
11758
 
11700
11759
  Wazo.Phone.sendDTMF(tone, this.callSession);
11701
11760
  }
11702
11761
 
11703
11762
  async sendReinvite(newConstraints = null) {
11704
- logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11763
+ logger$3.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11705
11764
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
11706
11765
 
11707
11766
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -11760,7 +11819,7 @@ class Room extends Emitter {
11760
11819
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11761
11820
 
11762
11821
  this.on(this.ON_AUDIO_STREAM, stream => {
11763
- logger$9.info('on room audio stream');
11822
+ logger$3.info('on room audio stream');
11764
11823
 
11765
11824
  this.audioStream = stream;
11766
11825
  if (!this.roomAudioElement) {
@@ -11773,7 +11832,7 @@ class Room extends Emitter {
11773
11832
  });
11774
11833
 
11775
11834
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
11776
- logger$9.info('on room video stream', { streamId });
11835
+ logger$3.info('on room video stream', { streamId });
11777
11836
 
11778
11837
  this._mapMsid(sipSession.body.body);
11779
11838
 
@@ -11788,7 +11847,7 @@ class Room extends Emitter {
11788
11847
  });
11789
11848
 
11790
11849
  this.on(this.ON_REMOVE_STREAM, stream => {
11791
- logger$9.info('on room remove stream');
11850
+ logger$3.info('on room remove stream');
11792
11851
 
11793
11852
  const participant = this.participants.find(someParticipant =>
11794
11853
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -11920,7 +11979,7 @@ class Room extends Emitter {
11920
11979
  const requester = this._getParticipantFromCallId(origin.callId);
11921
11980
  if (requester) {
11922
11981
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
11923
- logger$9.info('trigger room requester status', { origin });
11982
+ logger$3.info('trigger room requester status', { origin });
11924
11983
  requester.triggerUpdate('REQUESTER_UPDATE');
11925
11984
  }
11926
11985
  break;
@@ -11951,24 +12010,24 @@ class Room extends Emitter {
11951
12010
 
11952
12011
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
11953
12012
  if (participant.user_uuid === session.uuid) {
11954
- logger$9.info('room current user joined');
12013
+ logger$3.info('room current user joined');
11955
12014
 
11956
12015
  // Retrieve participants via an API calls
11957
12016
  const conferenceId = this.sourceId || payload.data.conference_id;
11958
12017
  let response;
11959
12018
  try {
11960
12019
  if (this.meetingUuid) {
11961
- logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12020
+ logger$3.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
11962
12021
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
11963
12022
  } else {
11964
- logger$9.info('fetching conference participants', { conferenceId });
12023
+ logger$3.info('fetching conference participants', { conferenceId });
11965
12024
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
11966
12025
  }
11967
12026
  } catch (e) {
11968
- logger$9.error('room participants fetching, error', e);
12027
+ logger$3.error('room participants fetching, error', e);
11969
12028
  }
11970
12029
  if (response) {
11971
- logger$9.info('conference participants fetched', { nb: response.items.length });
12030
+ logger$3.info('conference participants fetched', { nb: response.items.length });
11972
12031
  participants = response.items.map(item => {
11973
12032
  const isMe = item.call_id === this.callId;
11974
12033
 
@@ -11995,7 +12054,7 @@ class Room extends Emitter {
11995
12054
  ? new Wazo.RemoteParticipant(this, participant)
11996
12055
  : null;
11997
12056
 
11998
- logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12057
+ logger$3.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
11999
12058
 
12000
12059
  if (remoteParticipant) {
12001
12060
  this.participants.push(remoteParticipant);
@@ -12160,12 +12219,12 @@ class Room extends Emitter {
12160
12219
 
12161
12220
  //
12162
12221
 
12163
- const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
12222
+ const logger$2 = IssueReporter$1.loggerFor('sdk-sip-room');
12164
12223
 
12165
- class SipRoom extends Room {
12224
+ class SipRoom extends Room$1 {
12166
12225
 
12167
12226
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12168
- logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
12227
+ logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12169
12228
 
12170
12229
  if (!room) {
12171
12230
  await Wazo.Phone.connect();
@@ -12181,7 +12240,7 @@ class SipRoom extends Room {
12181
12240
  room.setCallId(room.callSession.call.id);
12182
12241
  }
12183
12242
 
12184
- logger$a.info('connected to room', {
12243
+ logger$2.info('connected to room', {
12185
12244
  extension: room.extension,
12186
12245
  });
12187
12246
 
@@ -12189,7 +12248,7 @@ class SipRoom extends Room {
12189
12248
  }
12190
12249
 
12191
12250
  mute() {
12192
- logger$a.info('mute sip room');
12251
+ logger$2.info('mute sip room');
12193
12252
 
12194
12253
  Wazo.Phone.mute(this.callSession, false);
12195
12254
 
@@ -12197,7 +12256,7 @@ class SipRoom extends Room {
12197
12256
  }
12198
12257
 
12199
12258
  unmute() {
12200
- logger$a.info('unmute sip room');
12259
+ logger$2.info('unmute sip room');
12201
12260
 
12202
12261
  Wazo.Phone.unmute(this.callSession, false);
12203
12262
 
@@ -12404,6 +12463,14 @@ const createLocalVideoStream = async (options ) => createLocalStream('vid
12404
12463
 
12405
12464
  const createLocalAudioStream = async (options ) => createLocalStream('audio', options);
12406
12465
 
12466
+ /* */
12467
+ class SFUNotAvailableError extends Error {
12468
+ constructor(message = 'Sorry your user is not configured to support video conference') {
12469
+ super(message);
12470
+ this.name = 'SFUNotAvailableError';
12471
+ }
12472
+ }
12473
+
12407
12474
  //
12408
12475
 
12409
12476
 
@@ -12481,7 +12548,7 @@ class NotificationOptions {
12481
12548
 
12482
12549
 
12483
12550
  // Represents a conference room, like `9000`.
12484
- class Room$1 {
12551
+ class Room {
12485
12552
 
12486
12553
 
12487
12554
 
@@ -12502,7 +12569,7 @@ class Room$1 {
12502
12569
  }
12503
12570
 
12504
12571
  connect(callSession ) {
12505
- return new Room$1({ ...this, connectedCallSession: callSession });
12572
+ return new Room({ ...this, connectedCallSession: callSession });
12506
12573
  }
12507
12574
 
12508
12575
  has(callSession ) {
@@ -12511,7 +12578,7 @@ class Room$1 {
12511
12578
 
12512
12579
  addParticipant(uuid , extension , talking = null) {
12513
12580
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12514
- return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12581
+ return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12515
12582
  }
12516
12583
 
12517
12584
  return this;
@@ -12530,7 +12597,7 @@ class Room$1 {
12530
12597
  updatedParticipants.push(participant);
12531
12598
  }
12532
12599
 
12533
- return new Room$1({ ...this, participants: updatedParticipants });
12600
+ return new Room({ ...this, participants: updatedParticipants });
12534
12601
  }
12535
12602
 
12536
12603
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12546,7 +12613,7 @@ class Room$1 {
12546
12613
  updatedParticipants.push(participant);
12547
12614
  }
12548
12615
 
12549
- return new Room$1({ ...this, participants: updatedParticipants });
12616
+ return new Room({ ...this, participants: updatedParticipants });
12550
12617
  }
12551
12618
 
12552
12619
  hasCallWithId(id ) {
@@ -12554,18 +12621,18 @@ class Room$1 {
12554
12621
  }
12555
12622
 
12556
12623
  disconnect() {
12557
- return new Room$1({ ...this, connectedCallSession: null });
12624
+ return new Room({ ...this, connectedCallSession: null });
12558
12625
  }
12559
12626
 
12560
12627
  removeParticipantWithUUID(uuid ) {
12561
- return new Room$1({
12628
+ return new Room({
12562
12629
  ...this,
12563
12630
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12564
12631
  });
12565
12632
  }
12566
12633
 
12567
12634
  removeParticipantWithExtension(extension ) {
12568
- return new Room$1({
12635
+ return new Room({
12569
12636
  ...this,
12570
12637
  participants: this.participants.filter(participant => participant.extension !== extension),
12571
12638
  });
@@ -12576,7 +12643,7 @@ class Room$1 {
12576
12643
  }
12577
12644
 
12578
12645
  static newFrom(room ) {
12579
- return newFrom(room, Room$1);
12646
+ return newFrom(room, Room);
12580
12647
  }
12581
12648
  }
12582
12649
 
@@ -12883,11 +12950,11 @@ var wazoWebsocket = {
12883
12950
  resolve();
12884
12951
  };
12885
12952
 
12886
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
12953
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
12887
12954
  handleError(`Connection error : ${error}`);
12888
12955
  });
12889
12956
 
12890
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
12957
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
12891
12958
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12892
12959
  client.setOnHeartbeatTimeout(() => {
12893
12960
  handleError('No response to heartbeat');
@@ -12988,7 +13055,7 @@ var webrtc = {
12988
13055
  }),
12989
13056
  };
12990
13057
 
12991
- const parseCandidate$1 = line => {
13058
+ const parseCandidate = line => {
12992
13059
  let parts;
12993
13060
  // Parse both variants.
12994
13061
  if (line.indexOf('a=candidate:') === 0) {
@@ -13079,7 +13146,7 @@ var SymmetricNat = {
13079
13146
  }
13080
13147
 
13081
13148
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13082
- const cand = parseCandidate$1(e.candidate.candidate);
13149
+ const cand = parseCandidate(e.candidate.candidate);
13083
13150
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13084
13151
  candidates[cand.relatedPort].push(cand.port);
13085
13152
  } else if (!e.candidate) {
@@ -13147,7 +13214,7 @@ var iceIpv4 = {
13147
13214
  const rawCandidate = e.candidate.candidate;
13148
13215
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13149
13216
  hasSrflxOrRelay = true;
13150
- const candidate = parseCandidate$1(e.candidate.candidate);
13217
+ const candidate = parseCandidate(e.candidate.candidate);
13151
13218
  ips.push(candidate.ip);
13152
13219
  }
13153
13220
  } else if (!e.candidate) {
@@ -13184,7 +13251,7 @@ var checks = [
13184
13251
 
13185
13252
  //
13186
13253
 
13187
- const logger$b = IssueReporter$1.loggerFor('engine-check');
13254
+ const logger$1 = IssueReporter$1.loggerFor('engine-check');
13188
13255
 
13189
13256
  class Checker {
13190
13257
 
@@ -13202,28 +13269,28 @@ class Checker {
13202
13269
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13203
13270
  await this._addEngineVersion();
13204
13271
 
13205
- logger$b.info('Engine check starting');
13272
+ logger$1.info('Engine check starting');
13206
13273
 
13207
13274
  for (let i = 0; i < this.checks.length; i++) {
13208
13275
  const { name, check } = this.checks[i];
13209
13276
 
13210
- logger$b.info(`Checking ${name} ...`);
13277
+ logger$1.info(`Checking ${name} ...`);
13211
13278
 
13212
13279
  onCheckBegin(name);
13213
13280
  try {
13214
13281
  // eslint-disable-next-line no-await-in-loop
13215
13282
  const result = await check(this.server, this.session, this.externalAppConfig);
13216
- logger$b.info(`Checking ${name} success.`, { result });
13283
+ logger$1.info(`Checking ${name} success.`, { result });
13217
13284
 
13218
13285
  onCheckResult(name, result);
13219
13286
  } catch (e) {
13220
- logger$b.info(`Checking ${name} failure`, { message: e.message });
13287
+ logger$1.info(`Checking ${name} failure`, { message: e.message });
13221
13288
 
13222
13289
  onCheckResult(name, e);
13223
13290
  }
13224
13291
  }
13225
13292
 
13226
- logger$b.info('Engine check done.');
13293
+ logger$1.info('Engine check done.');
13227
13294
  }
13228
13295
 
13229
13296
  addCheck(check ) {
@@ -13247,7 +13314,7 @@ const Wazo = {
13247
13314
  Auth: Auth$1,
13248
13315
  Phone: Phone$1,
13249
13316
  Websocket: Websocket$1,
13250
- Room,
13317
+ Room: Room$1,
13251
13318
  SipRoom,
13252
13319
  RemoteParticipant,
13253
13320
  LocalParticipant,
@@ -13280,7 +13347,7 @@ const Wazo = {
13280
13347
  Session,
13281
13348
  Voicemail,
13282
13349
  Relocation,
13283
- ConferenceRoom: Room$1,
13350
+ ConferenceRoom: Room,
13284
13351
  CallSession,
13285
13352
  IndirectTransfer,
13286
13353
  SwitchboardCall,
@@ -13305,6 +13372,7 @@ const Wazo = {
13305
13372
  InvalidSubscription,
13306
13373
  InvalidAuthorization,
13307
13374
  CanceledCallError,
13375
+ SFUNotAvailableError,
13308
13376
  };
13309
13377
 
13310
13378
  if (window) {
@@ -13316,7 +13384,7 @@ if (global) {
13316
13384
 
13317
13385
  //
13318
13386
 
13319
- const logger$c = IssueReporter$1.loggerFor('simple-phone');
13387
+ const logger = IssueReporter$1.loggerFor('simple-phone');
13320
13388
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
13321
13389
  const protocolLogger = IssueReporter$1.loggerFor('sip');
13322
13390
 
@@ -13423,7 +13491,7 @@ class Phone extends Emitter {
13423
13491
  async disconnect() {
13424
13492
  if (this.phone) {
13425
13493
  if (this.phone.hasAnActiveCall()) {
13426
- logger$c.info('hangup call on disconnect');
13494
+ logger.info('hangup call on disconnect');
13427
13495
  // $FlowFixMe
13428
13496
  await this.phone.hangup();
13429
13497
  }
@@ -13446,13 +13514,13 @@ class Phone extends Emitter {
13446
13514
  }
13447
13515
 
13448
13516
  async hangup(callSession ) {
13449
- logger$c.info('hangup via simple phone', { callId: callSession.getId() });
13517
+ logger.info('hangup via simple phone', { callId: callSession.getId() });
13450
13518
 
13451
13519
  return this.phone && this.phone.hangup(callSession);
13452
13520
  }
13453
13521
 
13454
13522
  async accept(callSession , cameraEnabled ) {
13455
- logger$c.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
13523
+ logger.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
13456
13524
 
13457
13525
  return this.phone && this.phone.accept(callSession, cameraEnabled);
13458
13526
  }
@@ -13491,7 +13559,7 @@ class Phone extends Emitter {
13491
13559
  muteViaAPI(callSession ) {
13492
13560
  if (callSession && callSession.callId) {
13493
13561
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
13494
- logger$c.error('Mute via API, error', e);
13562
+ logger.error('Mute via API, error', e);
13495
13563
  });
13496
13564
  }
13497
13565
  }
@@ -13499,7 +13567,7 @@ class Phone extends Emitter {
13499
13567
  unmuteViaAPI(callSession ) {
13500
13568
  if (callSession && callSession.callId) {
13501
13569
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
13502
- logger$c.error('Unmute via API, error', e);
13570
+ logger.error('Unmute via API, error', e);
13503
13571
  });
13504
13572
  }
13505
13573
  }
@@ -13607,7 +13675,7 @@ class Phone extends Emitter {
13607
13675
 
13608
13676
  // @Deprecated
13609
13677
  getLocalMediaStream(callSession ) {
13610
- logger$c.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
13678
+ logger.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
13611
13679
 
13612
13680
  return this.phone && this.phone.getLocalStream(callSession);
13613
13681
  }
@@ -13630,20 +13698,20 @@ class Phone extends Emitter {
13630
13698
 
13631
13699
  // @Deprecated
13632
13700
  getRemoteStreamForCall(callSession ) {
13633
- logger$c.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
13701
+ logger.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
13634
13702
  return this.getRemoteStream(callSession);
13635
13703
  }
13636
13704
 
13637
13705
  // Returns remote streams directly from the peerConnection
13638
13706
  // @Deprecated
13639
13707
  getRemoteStreamsForCall(callSession ) {
13640
- logger$c.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
13708
+ logger.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
13641
13709
  return this.getLocalStream(callSession);
13642
13710
  }
13643
13711
 
13644
13712
  // @Deprecated
13645
13713
  getRemoteVideoStreamForCall(callSession ) {
13646
- logger$c.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
13714
+ logger.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
13647
13715
 
13648
13716
  return this.getRemoteVideoStream(callSession);
13649
13717
  }
@@ -13698,13 +13766,13 @@ class Phone extends Emitter {
13698
13766
 
13699
13767
  checkSfu() {
13700
13768
  if (!this.hasSfu()) {
13701
- throw new Error('Sorry your user is not configured to support video conference');
13769
+ throw new SFUNotAvailableError();
13702
13770
  }
13703
13771
  }
13704
13772
 
13705
13773
  _transferEvents() {
13706
13774
  this.unbind();
13707
- [...events, ...transportEvents].forEach(event => {
13775
+ [...events$1, ...transportEvents].forEach(event => {
13708
13776
  this.client.on(event, (...args) =>
13709
13777
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
13710
13778
  });