@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
package/esm/index.js CHANGED
@@ -460,11 +460,11 @@ var IssueReporter$1 = new IssueReporter();
460
460
 
461
461
  const methods = ['head', 'get', 'post', 'put', 'delete'];
462
462
 
463
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
463
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
464
464
 
465
465
  // Use a function here to be able to mock it in tests
466
466
  const realFetch = () => {
467
- if (typeof document !== 'undefined') {
467
+ if (typeof document !== 'undefined' && window.fetch) {
468
468
  // Browser
469
469
  return window.fetch;
470
470
  }
@@ -599,7 +599,7 @@ class ApiRequester {
599
599
  };
600
600
 
601
601
  if (this.refreshTokenPromise) {
602
- logger.info('A token is already refreshing, waiting ...', { url });
602
+ logger$c.info('A token is already refreshing, waiting ...', { url });
603
603
  await this.refreshTokenPromise;
604
604
  }
605
605
 
@@ -619,7 +619,7 @@ class ApiRequester {
619
619
  return promise.then(async (err ) => {
620
620
  // Check if the token is still valid
621
621
  if (firstCall && this._checkTokenExpired(response, err)) {
622
- logger.warn('token expired', { error: err.reason });
622
+ logger$c.warn('token expired', { error: err.reason });
623
623
  // Replay the call after refreshing the token
624
624
  return this._replayWithNewToken(err, path, method, body, headers, parse);
625
625
  }
@@ -629,7 +629,7 @@ class ApiRequester {
629
629
  : exceptionClass.fromResponse(err, response.status);
630
630
 
631
631
  if (this.shouldLogErrors) {
632
- logger.error('API error', error);
632
+ logger$c.error('API error', error);
633
633
  }
634
634
 
635
635
  throw error;
@@ -639,7 +639,7 @@ class ApiRequester {
639
639
  return newParse(response, isJson);
640
640
  }).catch(error => {
641
641
  if (this.shouldLogErrors) {
642
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
642
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
643
643
  }
644
644
 
645
645
  throw error;
@@ -667,13 +667,13 @@ class ApiRequester {
667
667
  ) {
668
668
  const isTokenNotFound = this._isTokenNotFound(err);
669
669
  let newPath = path;
670
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
670
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
671
671
 
672
672
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
673
673
 
674
674
  return this.refreshTokenPromise.then(() => {
675
675
  this.refreshTokenPromise = null;
676
- logger.info('token refreshed', { isTokenNotFound });
676
+ logger$c.info('token refreshed', { isTokenNotFound });
677
677
  if (isTokenNotFound) {
678
678
  const pathParts = path.split('/');
679
679
  pathParts.pop();
@@ -1924,7 +1924,7 @@ class Contact {
1924
1924
  this[key] = old[key] || this[key];
1925
1925
  });
1926
1926
 
1927
- if (old.lineState && !this.lineState) {
1927
+ if (old.lineState) {
1928
1928
  this.lineState = old.lineState;
1929
1929
  }
1930
1930
 
@@ -3254,8 +3254,10 @@ var updateFrom = (instance , from ) => {
3254
3254
 
3255
3255
 
3256
3256
 
3257
+
3257
3258
 
3258
3259
 
3260
+
3259
3261
 
3260
3262
 
3261
3263
 
@@ -3272,6 +3274,7 @@ var updateFrom = (instance , from ) => {
3272
3274
 
3273
3275
 
3274
3276
 
3277
+
3275
3278
 
3276
3279
 
3277
3280
  class CallSession {
@@ -3291,8 +3294,12 @@ class CallSession {
3291
3294
 
3292
3295
 
3293
3296
 
3297
+
3298
+
3294
3299
 
3295
3300
 
3301
+
3302
+
3296
3303
 
3297
3304
 
3298
3305
 
@@ -3330,6 +3337,8 @@ class CallSession {
3330
3337
 
3331
3338
 
3332
3339
 
3340
+
3341
+
3333
3342
 
3334
3343
  constructor({
3335
3344
  answered,
@@ -3343,6 +3352,8 @@ class CallSession {
3343
3352
  paused,
3344
3353
  ringing,
3345
3354
  startTime,
3355
+ creationTime,
3356
+ endTime,
3346
3357
  cameraEnabled,
3347
3358
  dialedExtension,
3348
3359
  sipCallId,
@@ -3355,12 +3366,15 @@ class CallSession {
3355
3366
  recording,
3356
3367
  recordingPaused,
3357
3368
  videoRemotelyDowngraded,
3369
+ sipSession,
3358
3370
  } ) {
3359
3371
  this.callId = callId;
3360
3372
  this.sipCallId = sipCallId;
3361
3373
  this.displayName = displayName;
3362
3374
  this.number = number;
3375
+ this.creationTime = creationTime;
3363
3376
  this.startTime = startTime;
3377
+ this.endTime = endTime;
3364
3378
  this.isCaller = isCaller;
3365
3379
  this.answered = answered;
3366
3380
  this.answeredBySystem = answeredBySystem;
@@ -3379,6 +3393,7 @@ class CallSession {
3379
3393
  this.recording = recording || false;
3380
3394
  this.recordingPaused = recordingPaused || false;
3381
3395
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3396
+ this.sipSession = sipSession;
3382
3397
 
3383
3398
  // Useful to compare instead of instanceof with minified code
3384
3399
  this.type = 'CallSession';
@@ -4137,7 +4152,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4137
4152
 
4138
4153
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4139
4154
 
4140
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4155
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4141
4156
 
4142
4157
  class CTIPhone extends Emitter {
4143
4158
 
@@ -4150,7 +4165,7 @@ class CTIPhone extends Emitter {
4150
4165
 
4151
4166
  constructor(session , isMobile = false, callbackAllLines = false) {
4152
4167
  super();
4153
- logger$1.info('CTI Phone created');
4168
+ logger$b.info('CTI Phone created');
4154
4169
  this.session = session;
4155
4170
  this.isMobile = isMobile;
4156
4171
  this.callbackAllLines = callbackAllLines;
@@ -4211,7 +4226,7 @@ class CTIPhone extends Emitter {
4211
4226
  }
4212
4227
 
4213
4228
  async makeCall(number , line ) {
4214
- logger$1.info('make CTI call', { number });
4229
+ logger$b.info('make CTI call', { number });
4215
4230
 
4216
4231
  if (!number) {
4217
4232
  return null;
@@ -4234,7 +4249,7 @@ class CTIPhone extends Emitter {
4234
4249
  if (!callSession) {
4235
4250
  return Promise.resolve(null);
4236
4251
  }
4237
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4252
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4238
4253
 
4239
4254
  if (!this.currentCall) {
4240
4255
  this.currentCall = callSession.call;
@@ -4247,7 +4262,7 @@ class CTIPhone extends Emitter {
4247
4262
  if (!callSession) {
4248
4263
  return;
4249
4264
  }
4250
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4265
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4251
4266
 
4252
4267
  this.currentCall = undefined;
4253
4268
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4257,7 +4272,7 @@ class CTIPhone extends Emitter {
4257
4272
  if (!callSession) {
4258
4273
  return Promise.resolve(false);
4259
4274
  }
4260
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4275
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4261
4276
 
4262
4277
  try {
4263
4278
  await CallApi.cancelCall(callSession);
@@ -4268,7 +4283,7 @@ class CTIPhone extends Emitter {
4268
4283
  this.eventEmitter.emit('onCallEnded', callSession);
4269
4284
  return true;
4270
4285
  } catch (e) {
4271
- logger$1.error('hangup CTI call, error', e);
4286
+ logger$b.error('hangup CTI call, error', e);
4272
4287
 
4273
4288
  this.eventEmitter.emit('onCallFailed', callSession);
4274
4289
  return false;
@@ -4281,7 +4296,7 @@ class CTIPhone extends Emitter {
4281
4296
  if (!callSession) {
4282
4297
  return;
4283
4298
  }
4284
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4299
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4285
4300
 
4286
4301
  await CallApi.cancelCall(callSession);
4287
4302
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4291,7 +4306,7 @@ class CTIPhone extends Emitter {
4291
4306
  if (!callSession) {
4292
4307
  return;
4293
4308
  }
4294
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4309
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4295
4310
 
4296
4311
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4297
4312
  }
@@ -4304,19 +4319,19 @@ class CTIPhone extends Emitter {
4304
4319
  if (!callSession) {
4305
4320
  return;
4306
4321
  }
4307
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4322
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4308
4323
 
4309
4324
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4310
4325
  }
4311
4326
 
4312
4327
  async cancelCTIIndirectTransfer(transferId ) {
4313
- logger$1.info('cancel CTI transfer', { transferId });
4328
+ logger$b.info('cancel CTI transfer', { transferId });
4314
4329
 
4315
4330
  return CallApi.cancelCallTransfer(transferId);
4316
4331
  }
4317
4332
 
4318
4333
  async confirmCTIIndirectTransfer(transferId ) {
4319
- logger$1.info('confirm CTI transfer', { transferId });
4334
+ logger$b.info('confirm CTI transfer', { transferId });
4320
4335
 
4321
4336
  return CallApi.confirmCallTransfer(transferId);
4322
4337
  }
@@ -4325,19 +4340,19 @@ class CTIPhone extends Emitter {
4325
4340
  if (!callSession) {
4326
4341
  return;
4327
4342
  }
4328
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4343
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4329
4344
 
4330
4345
  return CallApi.sendDTMF(callSession.callId, digits);
4331
4346
  }
4332
4347
 
4333
4348
  onConnectionMade() {
4334
- logger$1.info('on CTI connection made');
4349
+ logger$b.info('on CTI connection made');
4335
4350
 
4336
4351
  this.eventEmitter.emit('onCallAccepted');
4337
4352
  }
4338
4353
 
4339
4354
  async close() {
4340
- logger$1.info('CTI close');
4355
+ logger$b.info('CTI close');
4341
4356
 
4342
4357
  return Promise.resolve();
4343
4358
  }
@@ -4346,7 +4361,7 @@ class CTIPhone extends Emitter {
4346
4361
  if (!callSession) {
4347
4362
  return;
4348
4363
  }
4349
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4364
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4350
4365
 
4351
4366
  return CallApi.hold(callSession.callId);
4352
4367
  }
@@ -4355,7 +4370,7 @@ class CTIPhone extends Emitter {
4355
4370
  if (!callSession) {
4356
4371
  return;
4357
4372
  }
4358
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4373
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4359
4374
 
4360
4375
  return CallApi.resume(callSession.callId);
4361
4376
  }
@@ -4364,7 +4379,7 @@ class CTIPhone extends Emitter {
4364
4379
  if (!callSession) {
4365
4380
  return;
4366
4381
  }
4367
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4382
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4368
4383
 
4369
4384
  return CallApi.mute(callSession.callId);
4370
4385
  }
@@ -4373,7 +4388,7 @@ class CTIPhone extends Emitter {
4373
4388
  if (!callSession) {
4374
4389
  return;
4375
4390
  }
4376
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4391
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4377
4392
 
4378
4393
  return CallApi.unmute(callSession.callId);
4379
4394
  }
@@ -5382,7 +5397,7 @@ const AGENTD_VERSION = '1.0';
5382
5397
  const WEBHOOKD_VERSION = '1.0';
5383
5398
  const AMID_VERSION = '1.0';
5384
5399
 
5385
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5400
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5386
5401
 
5387
5402
  class ApiClient {
5388
5403
 
@@ -5434,12 +5449,12 @@ class ApiClient {
5434
5449
  }
5435
5450
 
5436
5451
  async forceRefreshToken() {
5437
- logger$2.info('forcing refresh token, calling callback');
5452
+ logger$a.info('forcing refresh token, calling callback');
5438
5453
  return this.refreshTokenCallback();
5439
5454
  }
5440
5455
 
5441
5456
  async refreshTokenCallback() {
5442
- logger$2.info('refresh token callback called', {
5457
+ logger$a.info('refresh token callback called', {
5443
5458
  refreshToken: this.refreshToken,
5444
5459
  refreshBackend: this.refreshBackend,
5445
5460
  refreshExpiration: this.refreshExpiration,
@@ -5457,7 +5472,7 @@ class ApiClient {
5457
5472
  this.isMobile,
5458
5473
  );
5459
5474
 
5460
- logger$2.info('token refreshed', { token: session.token });
5475
+ logger$a.info('token refreshed', { token: session.token });
5461
5476
 
5462
5477
  if (this.onRefreshToken) {
5463
5478
  this.onRefreshToken(session.token, session);
@@ -5512,7 +5527,7 @@ class ApiClient {
5512
5527
 
5513
5528
  /* */
5514
5529
 
5515
- const parseCandidate = (candidate ) => {
5530
+ const parseCandidate$1 = (candidate ) => {
5516
5531
  if (!candidate) {
5517
5532
  return null;
5518
5533
  }
@@ -5624,11 +5639,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5624
5639
 
5625
5640
  // $FlowFixMe
5626
5641
  setRemoteSessionDescription(sessionDescription ) {
5627
- const result = super.setRemoteSessionDescription(sessionDescription);
5642
+ try {
5643
+ const result = super.setRemoteSessionDescription(sessionDescription);
5628
5644
 
5629
- this.eventEmitter.emit('setDescription', sessionDescription);
5645
+ this.eventEmitter.emit('setDescription', sessionDescription);
5630
5646
 
5631
- return result;
5647
+ return result;
5648
+ } catch (error) {
5649
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5650
+ throw error;
5651
+ }
5632
5652
  }
5633
5653
 
5634
5654
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -5666,7 +5686,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5666
5686
  this.peerConnectionDelegate.onicecandidate = event => {
5667
5687
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5668
5688
  if (event.candidate) {
5669
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5689
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5670
5690
  }
5671
5691
  };
5672
5692
 
@@ -6130,7 +6150,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6130
6150
  const SEND_STATS_DELAY = 5000;
6131
6151
 
6132
6152
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6133
- const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6153
+ const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6134
6154
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6135
6155
 
6136
6156
  // events
@@ -6144,14 +6164,14 @@ const TRANSPORT_ERROR = 'transportError';
6144
6164
  const MESSAGE = 'message';
6145
6165
  const ACCEPTED = 'accepted';
6146
6166
  const REJECTED = 'rejected';
6147
- const ON_TRACK = 'onTrack';
6148
- const ON_REINVITE = 'reinvite';
6167
+ const ON_TRACK$1 = 'onTrack';
6168
+ const ON_REINVITE$1 = 'reinvite';
6149
6169
  const ON_ERROR = 'onError';
6150
6170
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6151
- const ON_NETWORK_STATS = 'onNetworkStats';
6152
- const ON_DISCONNECTED = 'onDisconnected';
6171
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6172
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6153
6173
 
6154
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6174
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6155
6175
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6156
6176
  class CanceledCallError extends Error {}
6157
6177
 
@@ -6287,12 +6307,12 @@ class WebRTCClient extends Emitter {
6287
6307
  this.MESSAGE = MESSAGE;
6288
6308
  this.ACCEPTED = ACCEPTED;
6289
6309
  this.REJECTED = REJECTED;
6290
- this.ON_TRACK = ON_TRACK;
6291
- this.ON_REINVITE = ON_REINVITE;
6310
+ this.ON_TRACK = ON_TRACK$1;
6311
+ this.ON_REINVITE = ON_REINVITE$1;
6292
6312
  this.ON_ERROR = ON_ERROR;
6293
6313
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6294
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6295
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6314
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6315
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6296
6316
  }
6297
6317
 
6298
6318
  configureMedia(media ) {
@@ -6309,13 +6329,13 @@ class WebRTCClient extends Emitter {
6309
6329
 
6310
6330
  createUserAgent(configOverrides ) {
6311
6331
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6312
- logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6332
+ logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6313
6333
 
6314
6334
  webRTCConfiguration.delegate = {
6315
6335
  onConnect: this.onConnect.bind(this),
6316
6336
  onDisconnect: this.onDisconnect.bind(this),
6317
6337
  onInvite: (invitation ) => {
6318
- logger$3.info('sdk webrtc on invite', {
6338
+ logger$9.info('sdk webrtc on invite', {
6319
6339
  method: 'delegate.onInvite',
6320
6340
  id: invitation.id,
6321
6341
  remoteURI: invitation.remoteURI,
@@ -6358,7 +6378,7 @@ class WebRTCClient extends Emitter {
6358
6378
  }
6359
6379
 
6360
6380
  onConnect() {
6361
- logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6381
+ logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6362
6382
  this.eventEmitter.emit(CONNECTED);
6363
6383
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6364
6384
  this.registerer.waitingToggle(false);
@@ -6367,7 +6387,7 @@ class WebRTCClient extends Emitter {
6367
6387
  }
6368
6388
 
6369
6389
  async onDisconnect(error ) {
6370
- logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6390
+ logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6371
6391
  this.connectionPromise = null;
6372
6392
  // The UA will attempt to reconnect automatically when an error occurred
6373
6393
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6392,37 +6412,37 @@ class WebRTCClient extends Emitter {
6392
6412
  };
6393
6413
 
6394
6414
  if (this.skipRegister) {
6395
- logger$3.info('sdk webrtc skip register...', logInfo);
6415
+ logger$9.info('sdk webrtc skip register...', logInfo);
6396
6416
  return Promise.resolve();
6397
6417
  }
6398
6418
 
6399
- logger$3.info('sdk webrtc registering...', logInfo);
6419
+ logger$9.info('sdk webrtc registering...', logInfo);
6400
6420
 
6401
6421
  if (!this.userAgent) {
6402
- logger$3.info('sdk webrtc recreating User Agent');
6422
+ logger$9.info('sdk webrtc recreating User Agent');
6403
6423
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6404
6424
  }
6405
6425
  if (!this.userAgent || this.isRegistered()) {
6406
- logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6426
+ logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6407
6427
  return Promise.resolve();
6408
6428
  }
6409
6429
 
6410
6430
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6411
- logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6431
+ logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6412
6432
  return Promise.resolve();
6413
6433
  }
6414
6434
 
6415
6435
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6416
6436
 
6417
6437
  const onRegisterFailed = () => {
6418
- logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6438
+ logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6419
6439
  this.connectionPromise = null;
6420
6440
  if (this.registerer && this.registerer.waiting) {
6421
6441
  this.registerer.waitingToggle(false);
6422
6442
  }
6423
6443
 
6424
6444
  if (tries <= MAX_REGISTER_TRIES) {
6425
- logger$3.info('sdk webrtc registering, retrying...', { tries });
6445
+ logger$9.info('sdk webrtc registering, retrying...', { tries });
6426
6446
  setTimeout(() => this.register(tries + 1), 300);
6427
6447
  }
6428
6448
  };
@@ -6431,18 +6451,18 @@ class WebRTCClient extends Emitter {
6431
6451
  // Avoid race condition with the close method called just before register and setting userAgent to null
6432
6452
  // during the resolution of the primise.
6433
6453
  if (!this.userAgent) {
6434
- logger$3.info('sdk webrtc recreating User Agent after connection');
6454
+ logger$9.info('sdk webrtc recreating User Agent after connection');
6435
6455
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6436
6456
  }
6437
6457
 
6438
- logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6458
+ logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6439
6459
  this.registerer = new Registerer(this.userAgent, registerOptions);
6440
6460
  this.connectionPromise = null;
6441
6461
  this._monkeyPatchRegisterer(this.registerer);
6442
6462
 
6443
6463
  // Bind registerer events
6444
6464
  this.registerer.stateChange.addListener(newState => {
6445
- logger$3.info('sdk webrtc registering, state changed', { newState });
6465
+ logger$9.info('sdk webrtc registering, state changed', { newState });
6446
6466
 
6447
6467
  if (newState === RegistererState.Registered && this.registerer
6448
6468
  && this.registerer.state === RegistererState.Registered) {
@@ -6455,7 +6475,7 @@ class WebRTCClient extends Emitter {
6455
6475
  const options = {
6456
6476
  requestDelegate: {
6457
6477
  onReject: response => {
6458
- logger$3.error('sdk webrtc registering, rejected', { response });
6478
+ logger$9.error('sdk webrtc registering, rejected', { response });
6459
6479
 
6460
6480
  onRegisterFailed();
6461
6481
  },
@@ -6463,13 +6483,13 @@ class WebRTCClient extends Emitter {
6463
6483
  };
6464
6484
 
6465
6485
  return this.registerer.register(options).catch((e) => {
6466
- logger$3.error('sdk webrtc registering, error', e);
6486
+ logger$9.error('sdk webrtc registering, error', e);
6467
6487
 
6468
6488
  this.eventEmitter.emit(REGISTRATION_FAILED);
6469
6489
  return e;
6470
6490
  });
6471
6491
  }).catch(error => {
6472
- logger$3.error('sdk webrtc registering, transport error', error);
6492
+ logger$9.error('sdk webrtc registering, transport error', error);
6473
6493
  onRegisterFailed();
6474
6494
  });
6475
6495
  }
@@ -6498,21 +6518,21 @@ class WebRTCClient extends Emitter {
6498
6518
  }
6499
6519
 
6500
6520
  unregister() {
6501
- logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6521
+ logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6502
6522
  if (!this.registerer) {
6503
6523
  return Promise.resolve();
6504
6524
  }
6505
6525
 
6506
6526
  try {
6507
6527
  return this.registerer.unregister().then(() => {
6508
- logger$3.info('sdk webrtc unregistered');
6528
+ logger$9.info('sdk webrtc unregistered');
6509
6529
  this._cleanupRegister();
6510
6530
  }).catch(e => {
6511
- logger$3.error('sdk webrtc unregistering, promise error', e);
6531
+ logger$9.error('sdk webrtc unregistering, promise error', e);
6512
6532
  this._cleanupRegister();
6513
6533
  });
6514
6534
  } catch (e) {
6515
- logger$3.error('sdk webrtc unregistering, error', e);
6535
+ logger$9.error('sdk webrtc unregistering, error', e);
6516
6536
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6517
6537
  // error when the registerer is in a bad state
6518
6538
  this._cleanupRegister();
@@ -6520,7 +6540,7 @@ class WebRTCClient extends Emitter {
6520
6540
  }
6521
6541
 
6522
6542
  stop() {
6523
- logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6543
+ logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6524
6544
  if (!this.userAgent) {
6525
6545
  return Promise.resolve();
6526
6546
  }
@@ -6528,12 +6548,12 @@ class WebRTCClient extends Emitter {
6528
6548
  return this.userAgent.stop().then(() => {
6529
6549
  return this._cleanupRegister();
6530
6550
  }).catch(e => {
6531
- logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6551
+ logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6532
6552
  });
6533
6553
  }
6534
6554
 
6535
6555
  call(number , enableVideo , audioOnly = false, conference = false) {
6536
- logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6556
+ logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6537
6557
  const inviterOptions = {
6538
6558
  sessionDescriptionHandlerOptionsReInvite: {
6539
6559
  conference,
@@ -6564,7 +6584,7 @@ class WebRTCClient extends Emitter {
6564
6584
  this._onAccepted(session, response.session, true);
6565
6585
  },
6566
6586
  onReject: (response ) => {
6567
- logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6587
+ logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6568
6588
  this._stopSendingStats(session);
6569
6589
  this.stopNetworkMonitoring(session);
6570
6590
 
@@ -6587,11 +6607,11 @@ class WebRTCClient extends Emitter {
6587
6607
  }
6588
6608
 
6589
6609
  answer(session , enableVideo ) {
6590
- logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6610
+ logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6591
6611
 
6592
6612
  if (!session || !session.accept) {
6593
6613
  const error = 'No session to answer, or not an invitation';
6594
- logger$3.warn(error);
6614
+ logger$9.warn(error);
6595
6615
  return Promise.reject(new Error(error));
6596
6616
  }
6597
6617
  const options = {
@@ -6601,15 +6621,15 @@ class WebRTCClient extends Emitter {
6601
6621
  return session.accept(options).then(() => {
6602
6622
  if (session.isCanceled) {
6603
6623
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6604
- logger$3.error(message, { id: session.id });
6624
+ logger$9.error(message, { id: session.id });
6605
6625
  this.onCallEnded(session);
6606
6626
 
6607
6627
  throw new CanceledCallError(message);
6608
6628
  }
6609
- logger$3.info('sdk webrtc answer, accepted.');
6629
+ logger$9.info('sdk webrtc answer, accepted.');
6610
6630
  this._onAccepted(session);
6611
6631
  }).catch(e => {
6612
- logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6632
+ logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6613
6633
 
6614
6634
  throw e;
6615
6635
  });
@@ -6617,7 +6637,7 @@ class WebRTCClient extends Emitter {
6617
6637
 
6618
6638
  hangup(session ) {
6619
6639
  const { state, id } = session;
6620
- logger$3.info('sdk webrtc hangup call', { id, state });
6640
+ logger$9.info('sdk webrtc hangup call', { id, state });
6621
6641
 
6622
6642
  try {
6623
6643
  this._stopSendingStats(session);
@@ -6646,7 +6666,7 @@ class WebRTCClient extends Emitter {
6646
6666
 
6647
6667
  return bye();
6648
6668
  } catch (error) {
6649
- logger$3.warn('sdk webrtc hangup, error', error);
6669
+ logger$9.warn('sdk webrtc hangup, error', error);
6650
6670
  }
6651
6671
 
6652
6672
  return null;
@@ -6664,7 +6684,7 @@ class WebRTCClient extends Emitter {
6664
6684
  // Fetch and emit an event at `interval` with session network stats
6665
6685
  startNetworkMonitoring(session , interval = 1000) {
6666
6686
  const sessionId = this.getSipSessionId(session);
6667
- logger$3.info('starting network inspection', { id: sessionId });
6687
+ logger$9.info('starting network inspection', { id: sessionId });
6668
6688
 
6669
6689
  this.sessionNetworkStats[sessionId] = [];
6670
6690
 
@@ -6674,7 +6694,7 @@ class WebRTCClient extends Emitter {
6674
6694
  stopNetworkMonitoring(session ) {
6675
6695
  const sessionId = this.getSipSessionId(session);
6676
6696
  const exists = sessionId in this.networkMonitoringInterval;
6677
- logger$3.info('stopping network inspection', { id: sessionId, exists });
6697
+ logger$9.info('stopping network inspection', { id: sessionId, exists });
6678
6698
 
6679
6699
  if (exists) {
6680
6700
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6684,17 +6704,17 @@ class WebRTCClient extends Emitter {
6684
6704
  }
6685
6705
 
6686
6706
  reject(session ) {
6687
- logger$3.info('sdk webrtc reject call', { id: session.id });
6707
+ logger$9.info('sdk webrtc reject call', { id: session.id });
6688
6708
 
6689
6709
  try {
6690
6710
  return session.reject ? session.reject() : session.cancel();
6691
6711
  } catch (e) {
6692
- logger$3.warn('Error when rejecting call', e.message, e.stack);
6712
+ logger$9.warn('Error when rejecting call', e.message, e.stack);
6693
6713
  }
6694
6714
  }
6695
6715
 
6696
6716
  async close() {
6697
- logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6717
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6698
6718
  this._cleanupMedia();
6699
6719
  this.connectionPromise = null;
6700
6720
 
@@ -6725,7 +6745,7 @@ class WebRTCClient extends Emitter {
6725
6745
  // eg: "INVITE not rejectable in state Completed"
6726
6746
  }
6727
6747
  this.userAgent = null;
6728
- logger$3.info('sdk webrtc client closed');
6748
+ logger$9.info('sdk webrtc client closed');
6729
6749
  }
6730
6750
 
6731
6751
  getNumber(session ) {
@@ -6738,13 +6758,13 @@ class WebRTCClient extends Emitter {
6738
6758
  }
6739
6759
 
6740
6760
  mute(session ) {
6741
- logger$3.info('sdk webrtc mute', { id: session.id });
6761
+ logger$9.info('sdk webrtc mute', { id: session.id });
6742
6762
 
6743
6763
  this._toggleAudio(session, true);
6744
6764
  }
6745
6765
 
6746
6766
  unmute(session ) {
6747
- logger$3.info('sdk webrtc unmute', { id: session.id });
6767
+ logger$9.info('sdk webrtc unmute', { id: session.id });
6748
6768
 
6749
6769
  this._toggleAudio(session, false);
6750
6770
  }
@@ -6784,13 +6804,13 @@ class WebRTCClient extends Emitter {
6784
6804
  }
6785
6805
 
6786
6806
  toggleCameraOn(session ) {
6787
- logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6807
+ logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6788
6808
 
6789
6809
  this._toggleVideo(session, false);
6790
6810
  }
6791
6811
 
6792
6812
  toggleCameraOff(session ) {
6793
- logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6813
+ logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6794
6814
 
6795
6815
  this._toggleVideo(session, true);
6796
6816
  }
@@ -6799,7 +6819,7 @@ class WebRTCClient extends Emitter {
6799
6819
  const sessionId = this.getSipSessionId(session);
6800
6820
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6801
6821
 
6802
- logger$3.info('sdk webrtc hold', {
6822
+ logger$9.info('sdk webrtc hold', {
6803
6823
  sessionId,
6804
6824
  keys: Object.keys(this.heldSessions),
6805
6825
  pendingReinvite: !!session.pendingReinvite,
@@ -6848,7 +6868,7 @@ class WebRTCClient extends Emitter {
6848
6868
  const sessionId = this.getSipSessionId(session);
6849
6869
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
6850
6870
 
6851
- logger$3.info('sdk webrtc unhold', {
6871
+ logger$9.info('sdk webrtc unhold', {
6852
6872
  sessionId,
6853
6873
  keys: Object.keys(this.heldSessions),
6854
6874
  pendingReinvite: !!session.pendingReinvite,
@@ -6996,7 +7016,7 @@ class WebRTCClient extends Emitter {
6996
7016
  if (!session.sessionDescriptionHandler) {
6997
7017
  return;
6998
7018
  }
6999
- logger$3.info('Sending DTMF', {
7019
+ logger$9.info('Sending DTMF', {
7000
7020
  id: this.getSipSessionId(session),
7001
7021
  tone,
7002
7022
  });
@@ -7012,7 +7032,7 @@ class WebRTCClient extends Emitter {
7012
7032
  transfer(session , target ) {
7013
7033
  this.hold(session);
7014
7034
 
7015
- logger$3.info('Transfering a session', {
7035
+ logger$9.info('Transfering a session', {
7016
7036
  id: this.getSipSessionId(session),
7017
7037
  target,
7018
7038
  });
@@ -7034,17 +7054,17 @@ class WebRTCClient extends Emitter {
7034
7054
  atxfer(session ) {
7035
7055
  this.hold(session);
7036
7056
 
7037
- logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7057
+ logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7038
7058
 
7039
7059
  const result = {
7040
7060
  newSession: null,
7041
7061
  init: async (target ) => {
7042
- logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7062
+ logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7043
7063
 
7044
7064
  result.newSession = await this.call(target);
7045
7065
  },
7046
7066
  complete: () => {
7047
- logger$3.info('webrtc transfer completed', {
7067
+ logger$9.info('webrtc transfer completed', {
7048
7068
  id: this.getSipSessionId(session),
7049
7069
  referId: this.getSipSessionId(result.newSession),
7050
7070
  });
@@ -7065,7 +7085,7 @@ class WebRTCClient extends Emitter {
7065
7085
  return;
7066
7086
  }
7067
7087
 
7068
- logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7088
+ logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7069
7089
 
7070
7090
  try {
7071
7091
  sipSession.message({
@@ -7107,7 +7127,7 @@ class WebRTCClient extends Emitter {
7107
7127
  }
7108
7128
 
7109
7129
  changeAudioOutputVolume(volume ) {
7110
- logger$3.info('Changing audio output volume', { volume });
7130
+ logger$9.info('Changing audio output volume', { volume });
7111
7131
 
7112
7132
  Object.values(this.audioElements).forEach(audioElement => {
7113
7133
  if (audioElement instanceof HTMLAudioElement) {
@@ -7119,7 +7139,7 @@ class WebRTCClient extends Emitter {
7119
7139
  }
7120
7140
 
7121
7141
  changeAudioOutputDevice(id ) {
7122
- logger$3.info('Changing audio output device', { id });
7142
+ logger$9.info('Changing audio output device', { id });
7123
7143
 
7124
7144
  Object.values(this.audioElements).forEach(audioElement => {
7125
7145
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7136,7 +7156,7 @@ class WebRTCClient extends Emitter {
7136
7156
 
7137
7157
  changeAudioInputDevice(id , session ) {
7138
7158
  const currentId = this.getAudioDeviceId();
7139
- logger$3.info('setting audio input device', { id, currentId, session: !!session });
7159
+ logger$9.info('setting audio input device', { id, currentId, session: !!session });
7140
7160
 
7141
7161
  if (id === currentId) {
7142
7162
  return null;
@@ -7182,7 +7202,7 @@ class WebRTCClient extends Emitter {
7182
7202
 
7183
7203
  setVideoInputDevice(id ) {
7184
7204
  const currentId = this.getVideoDeviceId();
7185
- logger$3.info('setting video input device', { id, currentId });
7205
+ logger$9.info('setting video input device', { id, currentId });
7186
7206
 
7187
7207
  if (id === currentId) {
7188
7208
  return null;
@@ -7207,7 +7227,7 @@ class WebRTCClient extends Emitter {
7207
7227
  const sessionId = this.getSipSessionId(session);
7208
7228
  const localStream = this.getLocalStream(sessionId);
7209
7229
 
7210
- logger$3.info('changing video input device', { id, sessionId });
7230
+ logger$9.info('changing video input device', { id, sessionId });
7211
7231
 
7212
7232
  // Release old video stream
7213
7233
  if (localStream) {
@@ -7275,7 +7295,7 @@ class WebRTCClient extends Emitter {
7275
7295
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7276
7296
  const desktop = newConstraints && newConstraints.desktop;
7277
7297
 
7278
- logger$3.info('Sending reinvite', {
7298
+ logger$9.info('Sending reinvite', {
7279
7299
  id: this.getSipSessionId(sipSession),
7280
7300
  newConstraints,
7281
7301
  conference,
@@ -7313,7 +7333,7 @@ class WebRTCClient extends Emitter {
7313
7333
  sipSession.incomingInviteRequest.message.body = response.message.body;
7314
7334
  }
7315
7335
 
7316
- logger$3.info('on re-INVITE accepted', {
7336
+ logger$9.info('on re-INVITE accepted', {
7317
7337
  id: this.getSipSessionId(sipSession),
7318
7338
  wasMuted,
7319
7339
  shouldDoScreenSharing,
@@ -7331,7 +7351,7 @@ class WebRTCClient extends Emitter {
7331
7351
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7332
7352
  }
7333
7353
 
7334
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7354
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7335
7355
  },
7336
7356
  },
7337
7357
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7488,7 +7508,7 @@ class WebRTCClient extends Emitter {
7488
7508
  }
7489
7509
 
7490
7510
  startHeartbeat() {
7491
- logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7511
+ logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7492
7512
  if (!this.userAgent) {
7493
7513
  this.heartbeat.stop();
7494
7514
  return;
@@ -7501,7 +7521,7 @@ class WebRTCClient extends Emitter {
7501
7521
  }
7502
7522
 
7503
7523
  stopHeartbeat() {
7504
- logger$3.info('sdk webrtc stop heartbeat');
7524
+ logger$9.info('sdk webrtc stop heartbeat');
7505
7525
  this.heartbeat.stop();
7506
7526
  }
7507
7527
 
@@ -7522,7 +7542,7 @@ class WebRTCClient extends Emitter {
7522
7542
  }
7523
7543
 
7524
7544
  attemptReconnection() {
7525
- logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7545
+ logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7526
7546
  if (!this.userAgent) {
7527
7547
  return;
7528
7548
  }
@@ -7547,7 +7567,7 @@ class WebRTCClient extends Emitter {
7547
7567
  return;
7548
7568
  }
7549
7569
 
7550
- logger$3.info('setting local media stream', {
7570
+ logger$9.info('setting local media stream', {
7551
7571
  sipSessionId,
7552
7572
  tracks: newStream ? newStream.getTracks() : null,
7553
7573
  });
@@ -7564,7 +7584,7 @@ class WebRTCClient extends Emitter {
7564
7584
 
7565
7585
  const oldStream = this.getLocalStream(sipSessionId);
7566
7586
 
7567
- logger$3.info('updating local stream', {
7587
+ logger$9.info('updating local stream', {
7568
7588
  sipSessionId,
7569
7589
  oldStream: !!oldStream,
7570
7590
  tracks: newStream.getTracks(),
@@ -7584,7 +7604,7 @@ class WebRTCClient extends Emitter {
7584
7604
  const remoteStream = this.getRemoteStream(sessionId);
7585
7605
  const pc = this.getPeerConnection(sessionId);
7586
7606
 
7587
- logger$3.info('Updating remote stream', {
7607
+ logger$9.info('Updating remote stream', {
7588
7608
  sessionId,
7589
7609
  tracks: remoteStream ? remoteStream.getTracks() : null,
7590
7610
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7609,14 +7629,16 @@ class WebRTCClient extends Emitter {
7609
7629
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7610
7630
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7611
7631
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7632
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7612
7633
 
7613
- logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7634
+ logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7614
7635
 
7615
7636
  return {
7616
7637
  constraints: {
7617
7638
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7618
7639
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7619
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7640
+ video: screenSharing ? (isDesktop
7641
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7620
7642
  : this._getVideoConstraints(enableVideo),
7621
7643
  screen: screenSharing,
7622
7644
  desktop: isDesktop,
@@ -7659,7 +7681,7 @@ class WebRTCClient extends Emitter {
7659
7681
  }
7660
7682
 
7661
7683
  _onTransportError() {
7662
- logger$3.error('on transport error');
7684
+ logger$9.error('on transport error');
7663
7685
  this.eventEmitter.emit(TRANSPORT_ERROR);
7664
7686
  this.attemptReconnection();
7665
7687
  }
@@ -7668,7 +7690,7 @@ class WebRTCClient extends Emitter {
7668
7690
  const body = message && typeof message === 'object' ? message.data : message;
7669
7691
  if (body && body.indexOf('200 OK') !== -1) {
7670
7692
  if (this.hasHeartbeat()) {
7671
- logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7693
+ logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7672
7694
 
7673
7695
  this.heartbeat.onHeartbeat();
7674
7696
  if (this.heartbeatCb) {
@@ -7679,7 +7701,7 @@ class WebRTCClient extends Emitter {
7679
7701
  }
7680
7702
 
7681
7703
  async _onHeartbeatTimeout() {
7682
- logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7704
+ logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7683
7705
 
7684
7706
  if (this.heartbeatTimeoutCb) {
7685
7707
  this.heartbeatTimeoutCb();
@@ -7691,7 +7713,7 @@ class WebRTCClient extends Emitter {
7691
7713
  try {
7692
7714
  await this.userAgent.transport.disconnect();
7693
7715
  } catch (e) {
7694
- logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7716
+ logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7695
7717
  }
7696
7718
  }
7697
7719
 
@@ -7724,31 +7746,31 @@ class WebRTCClient extends Emitter {
7724
7746
  }
7725
7747
 
7726
7748
  _connectIfNeeded() {
7727
- logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7749
+ logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7728
7750
  if (!this.userAgent) {
7729
- logger$3.info('need to recreate User Agent');
7751
+ logger$9.info('need to recreate User Agent');
7730
7752
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7731
7753
  }
7732
7754
 
7733
7755
  if (this.isConnected()) {
7734
- logger$3.info('webrtc sdk, already connected');
7756
+ logger$9.info('webrtc sdk, already connected');
7735
7757
  return Promise.resolve();
7736
7758
  }
7737
7759
 
7738
7760
  if (this.isConnecting()) {
7739
- logger$3.info('webrtc sdk, already connecting...');
7761
+ logger$9.info('webrtc sdk, already connecting...');
7740
7762
 
7741
7763
  this.connectionPromise = this.userAgent.transport.connectPromise;
7742
7764
  return this.connectionPromise;
7743
7765
  }
7744
7766
 
7745
7767
  if (this.connectionPromise) {
7746
- logger$3.info('webrtc sdk, connection promise connecting...');
7768
+ logger$9.info('webrtc sdk, connection promise connecting...');
7747
7769
  // $FlowFixMe
7748
7770
  return this.connectionPromise;
7749
7771
  }
7750
7772
 
7751
- logger$3.info('WebRTC UA needs to connect');
7773
+ logger$9.info('WebRTC UA needs to connect');
7752
7774
 
7753
7775
  // Force UA to reconnect
7754
7776
  if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
@@ -7873,7 +7895,7 @@ class WebRTCClient extends Emitter {
7873
7895
 
7874
7896
  sdh.peerConnectionDelegate = {
7875
7897
  onicecandidateerror: (error ) => {
7876
- logger$3.error('on icecandidate error', {
7898
+ logger$9.error('on icecandidate error', {
7877
7899
  address: error.address,
7878
7900
  port: error.port,
7879
7901
  errorCode: error.errorCode,
@@ -7902,7 +7924,7 @@ class WebRTCClient extends Emitter {
7902
7924
  updatedNumber = session.assertedIdentity.uri.normal.user;
7903
7925
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
7904
7926
  }
7905
- logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7927
+ logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7906
7928
 
7907
7929
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
7908
7930
 
@@ -7918,12 +7940,12 @@ class WebRTCClient extends Emitter {
7918
7940
 
7919
7941
  this._setupMedias(session);
7920
7942
 
7921
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7943
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7922
7944
  };
7923
7945
  }
7924
7946
 
7925
7947
  _onAccepted(session , sessionDialog , withEvent = true) {
7926
- logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7948
+ logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7927
7949
 
7928
7950
  this.storeSipSession(session);
7929
7951
 
@@ -7935,14 +7957,14 @@ class WebRTCClient extends Emitter {
7935
7957
  const onTrack = (event ) => {
7936
7958
  const isAudioOnly = this._isAudioOnly(session);
7937
7959
  const { kind, label, readyState, id, muted } = event.track;
7938
- logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7960
+ logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7939
7961
 
7940
7962
  // Stop video track in audio only mode
7941
7963
  if (isAudioOnly && kind === 'video') {
7942
7964
  event.track.stop();
7943
7965
  }
7944
7966
 
7945
- this.eventEmitter.emit(ON_TRACK, session, event);
7967
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
7946
7968
  };
7947
7969
 
7948
7970
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -7951,12 +7973,14 @@ class WebRTCClient extends Emitter {
7951
7973
 
7952
7974
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7953
7975
 
7954
- pc.oniceconnectionstatechange = () => {
7955
- logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
7956
- if (pc.iceConnectionState === 'disconnected') {
7957
- this.eventEmitter.emit(ON_DISCONNECTED);
7958
- }
7959
- };
7976
+ if (pc) {
7977
+ pc.oniceconnectionstatechange = () => {
7978
+ logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
7979
+ if (pc.iceConnectionState === 'disconnected') {
7980
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
7981
+ }
7982
+ };
7983
+ }
7960
7984
 
7961
7985
  if (withEvent) {
7962
7986
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8125,10 +8149,10 @@ class WebRTCClient extends Emitter {
8125
8149
 
8126
8150
  _stopSendingStats(session ) {
8127
8151
  const sessionId = this.getSipSessionId(session);
8128
- logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8152
+ logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8129
8153
 
8130
8154
  if (sessionId in this.statsIntervals) {
8131
- logger$3.trace('Stop sending stats for call', { sessionId });
8155
+ logger$9.trace('Stop sending stats for call', { sessionId });
8132
8156
  this.statsIntervals[sessionId]();
8133
8157
  delete this.statsIntervals[sessionId];
8134
8158
  }
@@ -8144,7 +8168,7 @@ class WebRTCClient extends Emitter {
8144
8168
  try {
8145
8169
  await this.userAgent.transport.disconnect();
8146
8170
  } catch (e) {
8147
- logger$3.error('WebRTC transport disconnect, error', e);
8171
+ logger$9.error('WebRTC transport disconnect, error', e);
8148
8172
  }
8149
8173
  }
8150
8174
  }
@@ -8166,13 +8190,17 @@ class WebRTCClient extends Emitter {
8166
8190
  const nbStats = this.sessionNetworkStats[sessionId].length;
8167
8191
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8168
8192
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8193
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8169
8194
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8170
8195
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8196
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8171
8197
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8172
8198
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8173
8199
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8174
- let audioBytesSent = 0;
8175
- let audioBytesReceived = 0;
8200
+ let audioBytesSent = 0; // content + header
8201
+ let audioBytesReceived = 0; // content + header
8202
+ let audioContentSent = 0; // useful to detect blank call
8203
+ let audioContentReceived = 0;
8176
8204
  let videoBytesSent = 0;
8177
8205
  let videoBytesReceived = 0;
8178
8206
  let transportSent = 0;
@@ -8182,6 +8210,7 @@ class WebRTCClient extends Emitter {
8182
8210
  stats.forEach(report => {
8183
8211
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8184
8212
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8213
+ audioContentSent += Number(report.bytesSent);
8185
8214
  }
8186
8215
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8187
8216
  audioBytesSent += Number(report.bytesSent);
@@ -8193,6 +8222,7 @@ class WebRTCClient extends Emitter {
8193
8222
  packetsLost += Number(report.packetsLost);
8194
8223
  networkStats.packetsReceived = Number(report.packetsReceived);
8195
8224
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8225
+ audioContentReceived += Number(report.bytesReceived);
8196
8226
  }
8197
8227
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8198
8228
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8221,10 +8251,17 @@ class WebRTCClient extends Emitter {
8221
8251
  });
8222
8252
 
8223
8253
  networkStats.packetsLost = packetsLost;
8254
+
8224
8255
  networkStats.totalAudioBytesSent = audioBytesSent;
8225
8256
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8226
8257
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8227
8258
  networkStats.audioBytesReceived = audioBytesReceived;
8259
+
8260
+ networkStats.totalAudioContentSent = audioContentSent;
8261
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8262
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8263
+ networkStats.audioContentReceived = audioContentReceived;
8264
+
8228
8265
  networkStats.totalVideoBytesSent = videoBytesSent;
8229
8266
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8230
8267
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8238,7 +8275,7 @@ class WebRTCClient extends Emitter {
8238
8275
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8239
8276
  + networkStats.transportSent;
8240
8277
 
8241
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8278
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8242
8279
  this.sessionNetworkStats[sessionId].push(networkStats);
8243
8280
  }
8244
8281
 
@@ -8246,7 +8283,7 @@ class WebRTCClient extends Emitter {
8246
8283
 
8247
8284
  //
8248
8285
 
8249
- const SOCKET_EVENTS = {
8286
+ const SOCKET_EVENTS$1 = {
8250
8287
  ON_OPEN: 'onopen',
8251
8288
  ON_MESSAGE: 'onmessage',
8252
8289
  ON_ERROR: 'onerror',
@@ -8342,7 +8379,7 @@ const BLACKLIST_EVENTS = [
8342
8379
  ];
8343
8380
 
8344
8381
  const HEARTBEAT_ENGINE_VERSION = '20.09';
8345
- const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
8382
+ const logger$8 = IssueReporter$1.loggerFor('wazo-ws');
8346
8383
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
8347
8384
 
8348
8385
  class WebSocketClient extends Emitter {
@@ -8391,24 +8428,24 @@ class WebSocketClient extends Emitter {
8391
8428
  }
8392
8429
 
8393
8430
  connect() {
8394
- logger$4.info('connect method started', { host: this.host, token: this.token });
8431
+ logger$8.info('connect method started', { host: this.host, token: this.token });
8395
8432
  this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
8396
8433
  if (this.options.binaryType) {
8397
8434
  this.socket.binaryType = this.options.binaryType;
8398
8435
  }
8399
8436
 
8400
8437
  this.socket.onopen = () => {
8401
- logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
8402
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
8438
+ logger$8.info('on Wazo WS open', { method: 'connect', host: this.host });
8439
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
8403
8440
  };
8404
8441
 
8405
8442
  this.socket.onerror = event => {
8406
- logger$4.error('on Wazo WS error', event.target);
8407
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
8443
+ logger$8.error('on Wazo WS error', event.target);
8444
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
8408
8445
  };
8409
8446
 
8410
8447
  this.socket.onmessage = (event ) => {
8411
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
8448
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
8412
8449
 
8413
8450
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
8414
8451
  let { name } = message;
@@ -8433,7 +8470,7 @@ class WebSocketClient extends Emitter {
8433
8470
 
8434
8471
  this.socket.onclose = event => {
8435
8472
  // Can't be converted to JSON (circular structure)
8436
- logger$4.info('on Wazo WS close', {
8473
+ logger$8.info('on Wazo WS close', {
8437
8474
  reason: event.reason,
8438
8475
  code: event.code,
8439
8476
  readyState: event.target.readyState,
@@ -8441,22 +8478,22 @@ class WebSocketClient extends Emitter {
8441
8478
  token: this.token,
8442
8479
  });
8443
8480
  this.initialized = false;
8444
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
8481
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
8445
8482
 
8446
8483
  switch (event.code) {
8447
8484
  case 4002:
8448
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
8485
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
8449
8486
  break;
8450
8487
  }
8451
8488
  };
8452
8489
 
8453
8490
  this.socket.onerror = event => {
8454
- logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8491
+ logger$8.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8455
8492
  };
8456
8493
  }
8457
8494
 
8458
8495
  close(force = false) {
8459
- logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8496
+ logger$8.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8460
8497
 
8461
8498
  if (!this.socket) {
8462
8499
  return;
@@ -8474,7 +8511,7 @@ class WebSocketClient extends Emitter {
8474
8511
 
8475
8512
  updateToken(token ) {
8476
8513
  this.token = token;
8477
- logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8514
+ logger$8.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8478
8515
 
8479
8516
  if (this.socket) {
8480
8517
  // If still connected, send the token to the WS
@@ -8492,7 +8529,7 @@ class WebSocketClient extends Emitter {
8492
8529
  }
8493
8530
 
8494
8531
  startHeartbeat() {
8495
- logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8532
+ logger$8.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8496
8533
 
8497
8534
  if (!this.socket) {
8498
8535
  this.heartbeat.stop();
@@ -8506,7 +8543,7 @@ class WebSocketClient extends Emitter {
8506
8543
  }
8507
8544
 
8508
8545
  stopHeartbeat() {
8509
- logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8546
+ logger$8.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8510
8547
 
8511
8548
  this.heartbeat.stop();
8512
8549
  }
@@ -8536,7 +8573,7 @@ class WebSocketClient extends Emitter {
8536
8573
  }
8537
8574
 
8538
8575
  reconnect(reason ) {
8539
- logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8576
+ logger$8.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8540
8577
  if (!this.socket) {
8541
8578
  return;
8542
8579
  }
@@ -8561,7 +8598,7 @@ class WebSocketClient extends Emitter {
8561
8598
  break;
8562
8599
  case 'start':
8563
8600
  this.initialized = true;
8564
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
8601
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
8565
8602
  break;
8566
8603
  default:
8567
8604
  this.eventEmitter.emit('message', message);
@@ -8592,7 +8629,7 @@ class WebSocketClient extends Emitter {
8592
8629
  this.close();
8593
8630
  }
8594
8631
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
8595
- logger$4.log('Wazo WS url computed to reconnect', { url });
8632
+ logger$8.log('Wazo WS url computed to reconnect', { url });
8596
8633
 
8597
8634
  return url;
8598
8635
  }
@@ -8600,15 +8637,15 @@ class WebSocketClient extends Emitter {
8600
8637
  _onHeartbeat(message ) {
8601
8638
  if (message.payload === 'pong') {
8602
8639
  this.heartbeat.onHeartbeat();
8603
- logger$4.log('on heartbeat received from Wazo WS');
8640
+ logger$8.log('on heartbeat received from Wazo WS');
8604
8641
  }
8605
8642
  }
8606
8643
 
8607
8644
  async _onHeartbeatTimeout() {
8608
- logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
8645
+ logger$8.log('heartbeat timed out', { host: this.host, token: this.token });
8609
8646
 
8610
8647
  this.close();
8611
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
8648
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
8612
8649
 
8613
8650
  if (this.onHeartBeatTimeout) {
8614
8651
  this.onHeartBeatTimeout();
@@ -8688,7 +8725,7 @@ WebSocketClient.eventLists = [
8688
8725
 
8689
8726
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8690
8727
  __proto__: null,
8691
- SOCKET_EVENTS: SOCKET_EVENTS,
8728
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
8692
8729
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
8693
8730
  FAVORITE_ADDED: FAVORITE_ADDED,
8694
8731
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -8759,6 +8796,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8759
8796
  'default': WebSocketClient
8760
8797
  });
8761
8798
 
8799
+ /* */
8800
+ class SFUNotAvailableError extends Error {
8801
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8802
+ super(message);
8803
+ this.name = 'SFUNotAvailableError';
8804
+ }
8805
+ }
8806
+
8762
8807
  var COUNTRIES = {
8763
8808
  BELGIUM: 'BE',
8764
8809
  CANADA: 'CA',
@@ -8921,7 +8966,7 @@ class NotificationOptions {
8921
8966
 
8922
8967
 
8923
8968
  // Represents a conference room, like `9000`.
8924
- class Room {
8969
+ class Room$1 {
8925
8970
 
8926
8971
 
8927
8972
 
@@ -8942,7 +8987,7 @@ class Room {
8942
8987
  }
8943
8988
 
8944
8989
  connect(callSession ) {
8945
- return new Room({ ...this, connectedCallSession: callSession });
8990
+ return new Room$1({ ...this, connectedCallSession: callSession });
8946
8991
  }
8947
8992
 
8948
8993
  has(callSession ) {
@@ -8951,7 +8996,7 @@ class Room {
8951
8996
 
8952
8997
  addParticipant(uuid , extension , talking = null) {
8953
8998
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
8954
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
8999
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
8955
9000
  }
8956
9001
 
8957
9002
  return this;
@@ -8970,7 +9015,7 @@ class Room {
8970
9015
  updatedParticipants.push(participant);
8971
9016
  }
8972
9017
 
8973
- return new Room({ ...this, participants: updatedParticipants });
9018
+ return new Room$1({ ...this, participants: updatedParticipants });
8974
9019
  }
8975
9020
 
8976
9021
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -8986,7 +9031,7 @@ class Room {
8986
9031
  updatedParticipants.push(participant);
8987
9032
  }
8988
9033
 
8989
- return new Room({ ...this, participants: updatedParticipants });
9034
+ return new Room$1({ ...this, participants: updatedParticipants });
8990
9035
  }
8991
9036
 
8992
9037
  hasCallWithId(id ) {
@@ -8994,18 +9039,18 @@ class Room {
8994
9039
  }
8995
9040
 
8996
9041
  disconnect() {
8997
- return new Room({ ...this, connectedCallSession: null });
9042
+ return new Room$1({ ...this, connectedCallSession: null });
8998
9043
  }
8999
9044
 
9000
9045
  removeParticipantWithUUID(uuid ) {
9001
- return new Room({
9046
+ return new Room$1({
9002
9047
  ...this,
9003
9048
  participants: this.participants.filter(participant => participant.uuid !== uuid),
9004
9049
  });
9005
9050
  }
9006
9051
 
9007
9052
  removeParticipantWithExtension(extension ) {
9008
- return new Room({
9053
+ return new Room$1({
9009
9054
  ...this,
9010
9055
  participants: this.participants.filter(participant => participant.extension !== extension),
9011
9056
  });
@@ -9016,7 +9061,7 @@ class Room {
9016
9061
  }
9017
9062
 
9018
9063
  static newFrom(room ) {
9019
- return newFrom(room, Room);
9064
+ return newFrom(room, Room$1);
9020
9065
  }
9021
9066
  }
9022
9067
 
@@ -9156,11 +9201,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9156
9201
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9157
9202
  const ON_CALL_CANCELED = 'onCallCanceled';
9158
9203
  const ON_CALL_FAILED = 'onCallFailed';
9204
+ const ON_CALL_REJECTED = 'onCallRejected';
9159
9205
  const ON_CALL_ENDED = 'onCallEnded';
9160
9206
  const ON_CALL_ENDING = 'onCallEnding';
9161
9207
  const ON_MESSAGE = 'onMessage';
9162
- const ON_REINVITE$1 = 'reinvite';
9163
- const ON_TRACK$1 = 'onTrack';
9208
+ const ON_REINVITE = 'reinvite';
9209
+ const ON_TRACK = 'onTrack';
9164
9210
  const ON_AUDIO_STREAM = 'onAudioStream';
9165
9211
  const ON_VIDEO_STREAM = 'onVideoStream';
9166
9212
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -9175,15 +9221,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
9175
9221
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
9176
9222
  const ON_CALL_ERROR = 'onCallError';
9177
9223
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
9178
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
9224
+ const ON_NETWORK_STATS = 'onNetworkStats';
9179
9225
  const ON_CHAT = 'phone/ON_CHAT';
9180
9226
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9181
- const ON_DISCONNECTED$1 = 'onDisconnected';
9227
+ const ON_DISCONNECTED = 'onDisconnected';
9182
9228
 
9183
9229
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9184
9230
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
9185
9231
 
9186
- const events$1 = [
9232
+ const events = [
9187
9233
  ON_USER_AGENT,
9188
9234
  ON_REGISTERED,
9189
9235
  ON_UNREGISTERED,
@@ -9200,9 +9246,10 @@ const events$1 = [
9200
9246
  ON_CAMERA_DISABLED,
9201
9247
  ON_CALL_FAILED,
9202
9248
  ON_CALL_ENDED,
9249
+ ON_CALL_REJECTED,
9203
9250
  ON_MESSAGE,
9204
- ON_REINVITE$1,
9205
- ON_TRACK$1,
9251
+ ON_REINVITE,
9252
+ ON_TRACK,
9206
9253
  ON_AUDIO_STREAM,
9207
9254
  ON_VIDEO_STREAM,
9208
9255
  ON_REMOVE_STREAM,
@@ -9217,11 +9264,11 @@ const events$1 = [
9217
9264
  ON_CALL_ERROR,
9218
9265
  ON_CHAT,
9219
9266
  ON_SIGNAL,
9220
- ON_NETWORK_STATS$1,
9221
- ON_DISCONNECTED$1,
9267
+ ON_NETWORK_STATS,
9268
+ ON_DISCONNECTED,
9222
9269
  ];
9223
9270
 
9224
- const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
9271
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
9225
9272
 
9226
9273
  class WebRTCPhone extends Emitter {
9227
9274
 
@@ -9294,7 +9341,7 @@ class WebRTCPhone extends Emitter {
9294
9341
  }).catch(error => {
9295
9342
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
9296
9343
  console.error('register error', error, error.message, error.stack);
9297
- logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
9344
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
9298
9345
  });
9299
9346
  }
9300
9347
 
@@ -9309,7 +9356,7 @@ class WebRTCPhone extends Emitter {
9309
9356
  if (!this.client) {
9310
9357
  return;
9311
9358
  }
9312
- logger$5.info('WebRTC phone stop');
9359
+ logger$7.info('WebRTC phone stop');
9313
9360
  this.client.stop();
9314
9361
  }
9315
9362
 
@@ -9324,11 +9371,12 @@ class WebRTCPhone extends Emitter {
9324
9371
  async sendReinvite(callSession , constraints = null, conference = false,
9325
9372
  audioOnly = false, iceRestart = false) {
9326
9373
  const sipSession = this.findSipSession(callSession);
9327
- logger$5.info('WebRTC phone - send reinvite', {
9374
+ logger$7.info('WebRTC phone - send reinvite', {
9328
9375
  sessionId: sipSession ? sipSession.id : null,
9329
9376
  constraints,
9330
9377
  audioOnly,
9331
9378
  conference,
9379
+ iceRestart,
9332
9380
  });
9333
9381
 
9334
9382
  if (!sipSession) {
@@ -9361,7 +9409,7 @@ class WebRTCPhone extends Emitter {
9361
9409
  }
9362
9410
 
9363
9411
  startHeartbeat() {
9364
- logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9412
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9365
9413
  if (!this.client || this.client.hasHeartbeat()) {
9366
9414
  return;
9367
9415
  }
@@ -9370,7 +9418,7 @@ class WebRTCPhone extends Emitter {
9370
9418
  }
9371
9419
 
9372
9420
  stopHeartbeat() {
9373
- logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9421
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9374
9422
  if (!this.client) {
9375
9423
  return;
9376
9424
  }
@@ -9387,7 +9435,7 @@ class WebRTCPhone extends Emitter {
9387
9435
  }
9388
9436
 
9389
9437
  reconnect() {
9390
- logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
9438
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
9391
9439
  if (!this.client) {
9392
9440
  return;
9393
9441
  }
@@ -9428,7 +9476,7 @@ class WebRTCPhone extends Emitter {
9428
9476
  return false;
9429
9477
  }
9430
9478
 
9431
- logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9479
+ logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9432
9480
 
9433
9481
  this.client.downgradeToAudio(sipSession);
9434
9482
 
@@ -9451,7 +9499,7 @@ class WebRTCPhone extends Emitter {
9451
9499
  return Promise.resolve(false);
9452
9500
  }
9453
9501
 
9454
- logger$5.info('Upgrade to video', {
9502
+ logger$7.info('Upgrade to video', {
9455
9503
  id: callSession ? callSession.getId() : null,
9456
9504
  constraints,
9457
9505
  isConference,
@@ -9491,7 +9539,7 @@ class WebRTCPhone extends Emitter {
9491
9539
 
9492
9540
  _sendReinviteMessage(callSession , isUpgrade ) {
9493
9541
  const sipSession = this.findSipSession(callSession);
9494
- logger$5.info('Sending reinvite message', {
9542
+ logger$7.info('Sending reinvite message', {
9495
9543
  id: callSession ? callSession.getId() : null,
9496
9544
  isUpgrade,
9497
9545
  });
@@ -9517,7 +9565,7 @@ class WebRTCPhone extends Emitter {
9517
9565
  // Monkey patch to know when canceled with the CANCEL message
9518
9566
  const onCancel = sipSession._onCancel.bind(sipSession);
9519
9567
  sipSession._onCancel = (message ) => {
9520
- logger$5.trace('on sip session canceled', { callId: message.callId });
9568
+ logger$7.trace('on sip session canceled', { callId: message.callId });
9521
9569
 
9522
9570
  onCancel(message);
9523
9571
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -9545,16 +9593,17 @@ class WebRTCPhone extends Emitter {
9545
9593
  this.audioOutputVolume,
9546
9594
  );
9547
9595
  case SessionState.Terminating:
9548
- logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9596
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9549
9597
 
9550
9598
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9551
9599
 
9552
9600
  break;
9553
9601
  case SessionState.Terminated: {
9554
- logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9602
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9555
9603
 
9556
9604
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9557
9605
  const callSession = this._createCallSession(sipSession);
9606
+ callSession.endTime = new Date();
9558
9607
  const wasCurrentSession = this._onCallTerminated(sipSession);
9559
9608
 
9560
9609
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9573,7 +9622,7 @@ class WebRTCPhone extends Emitter {
9573
9622
  const [stream] = event.streams;
9574
9623
  const kind = event && event.track && event.track.kind;
9575
9624
 
9576
- logger$5.info('on track stream called on the peer connection', {
9625
+ logger$7.info('on track stream called on the peer connection', {
9577
9626
  callId: this.getSipSessionId(sipSession),
9578
9627
  streamId: stream ? stream.id : null,
9579
9628
  tracks: stream ? stream.getTracks() : null,
@@ -9593,7 +9642,7 @@ class WebRTCPhone extends Emitter {
9593
9642
  };
9594
9643
 
9595
9644
  peerConnection.onremovestream = event => {
9596
- logger$5.info('on remove stream called on the peer connection', {
9645
+ logger$7.info('on remove stream called on the peer connection', {
9597
9646
  id: event.stream.id,
9598
9647
  tracks: event.stream.getTracks(),
9599
9648
  });
@@ -9603,7 +9652,7 @@ class WebRTCPhone extends Emitter {
9603
9652
  }
9604
9653
 
9605
9654
  async startScreenSharing(constraints , callSession ) {
9606
- logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9655
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9607
9656
 
9608
9657
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9609
9658
  if (!screenShareStream) {
@@ -9643,7 +9692,7 @@ class WebRTCPhone extends Emitter {
9643
9692
  return;
9644
9693
  }
9645
9694
 
9646
- logger$5.info('WebRTC phone - stop screen sharing', {
9695
+ logger$7.info('WebRTC phone - stop screen sharing', {
9647
9696
  restoreLocalStream,
9648
9697
  });
9649
9698
 
@@ -9699,7 +9748,7 @@ class WebRTCPhone extends Emitter {
9699
9748
  const pc = this.client.getPeerConnection(sipSessionId);
9700
9749
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9701
9750
 
9702
- logger$5.info('WebRTC phone - on screensharing', {
9751
+ logger$7.info('WebRTC phone - on screensharing', {
9703
9752
  hadVideo,
9704
9753
  id: this.getSipSessionId(sipSession),
9705
9754
  screenTrack,
@@ -9707,7 +9756,7 @@ class WebRTCPhone extends Emitter {
9707
9756
 
9708
9757
  if (screenTrack) {
9709
9758
  screenTrack.onended = () => {
9710
- logger$5.info('WebRTC phone - on screenshare ended', {
9759
+ logger$7.info('WebRTC phone - on screenshare ended', {
9711
9760
  hadVideo,
9712
9761
  id: this.getSipSessionId(sipSession),
9713
9762
  screenTrack,
@@ -9738,7 +9787,7 @@ class WebRTCPhone extends Emitter {
9738
9787
  }
9739
9788
 
9740
9789
  _onCallAccepted(sipSession , cameraEnabled ) {
9741
- logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9790
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9742
9791
 
9743
9792
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9744
9793
  this.currentSipSession = sipSession;
@@ -9756,7 +9805,7 @@ class WebRTCPhone extends Emitter {
9756
9805
  }
9757
9806
 
9758
9807
  changeAudioDevice(id ) {
9759
- logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9808
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9760
9809
  this.audioOutputDeviceId = id;
9761
9810
  this.client.changeAudioOutputDevice(id);
9762
9811
  }
@@ -9766,14 +9815,14 @@ class WebRTCPhone extends Emitter {
9766
9815
  }
9767
9816
 
9768
9817
  changeRingDevice(id ) {
9769
- logger$5.info('WebRTC phone - changing ring device', { id });
9818
+ logger$7.info('WebRTC phone - changing ring device', { id });
9770
9819
 
9771
9820
  this.audioRingDeviceId = id;
9772
9821
  }
9773
9822
 
9774
9823
  // volume is a value between 0 and 1
9775
9824
  changeAudioVolume(volume ) {
9776
- logger$5.info('WebRTC phone - changing audio volume', { volume });
9825
+ logger$7.info('WebRTC phone - changing audio volume', { volume });
9777
9826
 
9778
9827
  this.audioOutputVolume = volume;
9779
9828
  this.client.changeAudioOutputVolume(volume);
@@ -9781,32 +9830,33 @@ class WebRTCPhone extends Emitter {
9781
9830
 
9782
9831
  // volume is a value between 0 and 1
9783
9832
  changeRingVolume(volume ) {
9784
- logger$5.info('WebRTC phone - changing ring volume', { volume });
9833
+ logger$7.info('WebRTC phone - changing ring volume', { volume });
9785
9834
 
9786
9835
  this.audioRingVolume = volume;
9787
9836
  }
9788
9837
 
9789
9838
  changeAudioInputDevice(id ) {
9790
- logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9839
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9791
9840
 
9792
9841
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9793
9842
  }
9794
9843
 
9795
9844
  changeVideoInputDevice(id ) {
9796
- logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9845
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9797
9846
 
9798
9847
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9799
9848
  }
9800
9849
 
9801
9850
  changeSessionVideoInputDevice(id ) {
9802
- logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9851
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9803
9852
 
9804
9853
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9805
9854
  }
9806
9855
 
9807
9856
  _onCallTerminated(sipSession ) {
9808
- logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9857
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9809
9858
 
9859
+ const sipSessionId = this.getSipSessionId(sipSession);
9810
9860
  const callSession = this._createCallSession(sipSession);
9811
9861
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9812
9862
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9824,7 +9874,6 @@ class WebRTCPhone extends Emitter {
9824
9874
  }, 5);
9825
9875
  }
9826
9876
 
9827
- const sipSessionId = this.getSipSessionId(sipSession);
9828
9877
  if (sipSessionId) {
9829
9878
  this.removeIncomingSessions(sipSessionId);
9830
9879
  }
@@ -9839,7 +9888,7 @@ class WebRTCPhone extends Emitter {
9839
9888
  const hasIncomingCallSession = this.hasIncomingCallSession();
9840
9889
 
9841
9890
  // Re-trigger incoming call event for remaining incoming calls
9842
- logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9891
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9843
9892
  sipId: sipSession.id,
9844
9893
  shouldRetrigger,
9845
9894
  hasIncomingCallSession,
@@ -9930,37 +9979,37 @@ class WebRTCPhone extends Emitter {
9930
9979
 
9931
9980
  // Deprecated
9932
9981
  getLocalStreamForCall(callSession ) {
9933
- logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9982
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9934
9983
 
9935
9984
  return this.getLocalStream(callSession);
9936
9985
  }
9937
9986
 
9938
9987
  // Deprecated
9939
9988
  getRemoteStreamForCall(callSession ) {
9940
- logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9989
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9941
9990
 
9942
9991
  return this.getRemoteVideoStream(callSession);
9943
9992
  }
9944
9993
 
9945
9994
  getRemoteStreamsForCall(callSession ) {
9946
- logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9995
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9947
9996
 
9948
9997
  return this.getRemoteStream(callSession);
9949
9998
  }
9950
9999
 
9951
10000
  accept(callSession , cameraEnabled ) {
9952
- logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
10001
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9953
10002
  if (this.currentSipSession) {
9954
10003
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9955
10004
  }
9956
10005
 
9957
10006
  if (!callSession) {
9958
- logger$5.warn('no CallSession to accept.');
10007
+ logger$7.warn('no CallSession to accept.');
9959
10008
  return Promise.resolve(null);
9960
10009
  }
9961
10010
 
9962
10011
  if (callSession.getId() in this.acceptedSessions) {
9963
- logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
10012
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9964
10013
  return Promise.resolve(callSession.sipCallId);
9965
10014
  }
9966
10015
 
@@ -9972,24 +10021,24 @@ class WebRTCPhone extends Emitter {
9972
10021
  const sipSession = this.client.getSipSession(callSession.getId());
9973
10022
  if (sipSession) {
9974
10023
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
9975
- logger$5.warn('Trying to answer a terminated sipSession.');
10024
+ logger$7.warn('Trying to answer a terminated sipSession.');
9976
10025
 
9977
10026
  return Promise.resolve(null);
9978
10027
  }
9979
10028
 
9980
- logger$5.info('accept call, session found', { sipId: sipSession.id });
10029
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
9981
10030
 
9982
10031
  // $FlowFixMe
9983
10032
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9984
10033
  return callSession.sipCallId;
9985
10034
  }).catch(e => {
9986
- logger$5.error(e);
10035
+ logger$7.error(e);
9987
10036
  this.endCurrentCall(callSession);
9988
10037
  throw e;
9989
10038
  });
9990
10039
  }
9991
10040
 
9992
- logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
10041
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9993
10042
 
9994
10043
  return Promise.resolve(null);
9995
10044
  }
@@ -9999,7 +10048,7 @@ class WebRTCPhone extends Emitter {
9999
10048
  }
10000
10049
 
10001
10050
  async reject(callSession ) {
10002
- logger$5.info('reject WebRTC called', { id: callSession.getId() });
10051
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
10003
10052
 
10004
10053
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
10005
10054
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -10011,14 +10060,14 @@ class WebRTCPhone extends Emitter {
10011
10060
 
10012
10061
  const sipSession = this.findSipSession(callSession);
10013
10062
  if (sipSession) {
10014
- logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
10063
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
10015
10064
 
10016
10065
  this.client.hangup(sipSession);
10017
10066
  }
10018
10067
  }
10019
10068
 
10020
10069
  async ignore(callSession ) {
10021
- logger$5.info('WebRTC ignore', { id: callSession.getId() });
10070
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
10022
10071
 
10023
10072
  // kill the ring
10024
10073
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -10030,14 +10079,14 @@ class WebRTCPhone extends Emitter {
10030
10079
  const sipSession = this.findSipSession(callSession);
10031
10080
 
10032
10081
  if (sipSession) {
10033
- logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
10082
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
10034
10083
 
10035
10084
  return this.client.atxfer(sipSession);
10036
10085
  }
10037
10086
  }
10038
10087
 
10039
10088
  hold(callSession , withEvent = true, isConference = false) {
10040
- logger$5.info('WebRTC hold', { id: callSession.getId() });
10089
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
10041
10090
 
10042
10091
  const sipSession = this.findSipSession(callSession);
10043
10092
 
@@ -10052,18 +10101,18 @@ class WebRTCPhone extends Emitter {
10052
10101
  }
10053
10102
 
10054
10103
  resume(callSession , isConference = false, withEvent = true) {
10055
- logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
10104
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
10056
10105
 
10057
10106
  const sipSession = this.findSipSession(callSession);
10058
10107
  if (!sipSession) {
10059
10108
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
10060
10109
  }
10061
10110
 
10062
- logger$5.info('WebRTC resuming', { sipId: sipSession.id });
10111
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
10063
10112
 
10064
10113
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
10065
10114
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
10066
- logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
10115
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
10067
10116
  this.holdSipSession(this.currentSipSession, callSession);
10068
10117
  }
10069
10118
 
@@ -10088,7 +10137,7 @@ class WebRTCPhone extends Emitter {
10088
10137
  const sessionId = this.getSipSessionId(sipSession);
10089
10138
  const hasVideo = this.client.hasLocalVideo(sessionId);
10090
10139
 
10091
- logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10140
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10092
10141
 
10093
10142
  // Stop screenshre if needed
10094
10143
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -10119,7 +10168,7 @@ class WebRTCPhone extends Emitter {
10119
10168
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
10120
10169
  }
10121
10170
  const sessionId = this.getSipSessionId(sipSession);
10122
- logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
10171
+ logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
10123
10172
 
10124
10173
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
10125
10174
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -10163,14 +10212,14 @@ class WebRTCPhone extends Emitter {
10163
10212
  }
10164
10213
 
10165
10214
  mute(callSession , withEvent = true) {
10166
- logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10215
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10167
10216
 
10168
10217
  const sipSession = this.findSipSession(callSession);
10169
10218
  if (!sipSession) {
10170
10219
  return;
10171
10220
  }
10172
10221
 
10173
- logger$5.info('WebRTC muting', { sipId: sipSession.id });
10222
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
10174
10223
  this.client.mute(sipSession);
10175
10224
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
10176
10225
 
@@ -10184,14 +10233,14 @@ class WebRTCPhone extends Emitter {
10184
10233
  }
10185
10234
 
10186
10235
  unmute(callSession , withEvent = true) {
10187
- logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10236
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10188
10237
 
10189
10238
  const sipSession = this.findSipSession(callSession);
10190
10239
  if (!sipSession) {
10191
10240
  return;
10192
10241
  }
10193
10242
 
10194
- logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
10243
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
10195
10244
  this.client.unmute(sipSession);
10196
10245
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
10197
10246
 
@@ -10218,7 +10267,7 @@ class WebRTCPhone extends Emitter {
10218
10267
  if (!sipSession) {
10219
10268
  return;
10220
10269
  }
10221
- logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
10270
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
10222
10271
 
10223
10272
  this.client.toggleCameraOn(sipSession);
10224
10273
 
@@ -10230,7 +10279,7 @@ class WebRTCPhone extends Emitter {
10230
10279
  if (!sipSession) {
10231
10280
  return;
10232
10281
  }
10233
- logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
10282
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
10234
10283
 
10235
10284
  this.client.toggleCameraOff(sipSession);
10236
10285
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -10242,7 +10291,7 @@ class WebRTCPhone extends Emitter {
10242
10291
  return;
10243
10292
  }
10244
10293
 
10245
- logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
10294
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
10246
10295
  this.client.sendDTMF(sipSession, tone);
10247
10296
  }
10248
10297
 
@@ -10250,7 +10299,7 @@ class WebRTCPhone extends Emitter {
10250
10299
  // @TODO: line is not used here
10251
10300
  async makeCall(number , line , cameraEnabled ,
10252
10301
  audioOnly = false, conference = false) {
10253
- logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
10302
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
10254
10303
  if (!number) {
10255
10304
  return Promise.resolve(null);
10256
10305
  }
@@ -10260,7 +10309,7 @@ class WebRTCPhone extends Emitter {
10260
10309
  }
10261
10310
  if (this.currentSipSession) {
10262
10311
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10263
- logger$5.warn('Unable to hold current session when making another call', e);
10312
+ logger$7.warn('Unable to hold current session when making another call', e);
10264
10313
  });
10265
10314
  }
10266
10315
 
@@ -10270,10 +10319,11 @@ class WebRTCPhone extends Emitter {
10270
10319
  this._bindEvents(sipSession);
10271
10320
  } catch (error) {
10272
10321
  console.warn(error);
10273
- logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10322
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10274
10323
  return Promise.resolve(null);
10275
10324
  }
10276
10325
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10326
+ callSession.creationTime = new Date();
10277
10327
 
10278
10328
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10279
10329
 
@@ -10298,7 +10348,7 @@ class WebRTCPhone extends Emitter {
10298
10348
  return;
10299
10349
  }
10300
10350
 
10301
- logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
10351
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
10302
10352
 
10303
10353
  this.client.transfer(sipSession, target);
10304
10354
  }
@@ -10307,7 +10357,7 @@ class WebRTCPhone extends Emitter {
10307
10357
  const sipSession = this.client.getSipSession(source.sipCallId);
10308
10358
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
10309
10359
 
10310
- logger$5.info('WebRTC indirect transfer', {
10360
+ logger$7.info('WebRTC indirect transfer', {
10311
10361
  sipId: sipSession ? sipSession.id : null,
10312
10362
  target: sipSessionTarget ? sipSessionTarget.id : null,
10313
10363
  });
@@ -10346,7 +10396,7 @@ class WebRTCPhone extends Emitter {
10346
10396
  return false;
10347
10397
  }
10348
10398
 
10349
- logger$5.info('WebRTC hangup', { sipId: sipSession.id });
10399
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
10350
10400
 
10351
10401
  const sipSessionId = this.getSipSessionId(sipSession);
10352
10402
 
@@ -10392,7 +10442,7 @@ class WebRTCPhone extends Emitter {
10392
10442
  endCurrentCall(callSession ) {
10393
10443
  const isCurrent = this.isCurrentCallSipSession(callSession);
10394
10444
 
10395
- logger$5.info('Ending current call', {
10445
+ logger$7.info('Ending current call', {
10396
10446
  id: callSession ? callSession.getId() : null,
10397
10447
  isCurrent,
10398
10448
  });
@@ -10416,7 +10466,7 @@ class WebRTCPhone extends Emitter {
10416
10466
  }
10417
10467
 
10418
10468
  async close() {
10419
- logger$5.info('WebRTC close');
10469
+ logger$7.info('WebRTC close');
10420
10470
 
10421
10471
  try {
10422
10472
  await Promise.race([
@@ -10424,7 +10474,7 @@ class WebRTCPhone extends Emitter {
10424
10474
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
10425
10475
  ]);
10426
10476
  } catch (e) {
10427
- logger$5.error('WebRTC close, unregister error', e);
10477
+ logger$7.error('WebRTC close, unregister error', e);
10428
10478
  }
10429
10479
 
10430
10480
  this.client.close();
@@ -10442,12 +10492,12 @@ class WebRTCPhone extends Emitter {
10442
10492
  }
10443
10493
 
10444
10494
  enableRinging() {
10445
- logger$5.info('WebRTC enable ringing');
10495
+ logger$7.info('WebRTC enable ringing');
10446
10496
  this.ringingEnabled = true;
10447
10497
  }
10448
10498
 
10449
10499
  disableRinging() {
10450
- logger$5.info('WebRTC disable ringing');
10500
+ logger$7.info('WebRTC disable ringing');
10451
10501
  this.ringingEnabled = false;
10452
10502
  }
10453
10503
 
@@ -10469,8 +10519,12 @@ class WebRTCPhone extends Emitter {
10469
10519
  }
10470
10520
 
10471
10521
  const sessionId = this.incomingSessions[0];
10522
+ const sipSession = this.client.getSipSession(sessionId);
10523
+ if (!sipSession) {
10524
+ return null;
10525
+ }
10472
10526
 
10473
- return this._createCallSession(this.client.getSipSession(sessionId));
10527
+ return this._createCallSession(sipSession);
10474
10528
  }
10475
10529
 
10476
10530
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10487,7 +10541,7 @@ class WebRTCPhone extends Emitter {
10487
10541
 
10488
10542
  // Deprecated
10489
10543
  getLocalMediaStream(callSession ) {
10490
- logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10544
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10491
10545
  return this.getLocalStream(callSession);
10492
10546
  }
10493
10547
 
@@ -10529,7 +10583,7 @@ class WebRTCPhone extends Emitter {
10529
10583
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10530
10584
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10531
10585
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10532
- logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10586
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10533
10587
 
10534
10588
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10535
10589
  this.incomingSessions.push(callSession.getId());
@@ -10548,11 +10602,12 @@ class WebRTCPhone extends Emitter {
10548
10602
  callSession);
10549
10603
  }
10550
10604
 
10605
+ callSession.creationTime = new Date();
10551
10606
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10552
10607
  });
10553
10608
 
10554
10609
  this.client.on(this.client.ON_REINVITE, (...args) => {
10555
- logger$5.info('WebRTC on reinvite', {
10610
+ logger$7.info('WebRTC on reinvite', {
10556
10611
  sessionId: args[0].id,
10557
10612
  inviteId: args[1].id,
10558
10613
  updatedCalleeName: args[2],
@@ -10572,7 +10627,7 @@ class WebRTCPhone extends Emitter {
10572
10627
  });
10573
10628
 
10574
10629
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10575
- logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10630
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10576
10631
 
10577
10632
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10578
10633
 
@@ -10583,22 +10638,29 @@ class WebRTCPhone extends Emitter {
10583
10638
  this.client.on('ended', () => {});
10584
10639
 
10585
10640
  this.client.on(this.client.ON_ERROR, e => {
10586
- logger$5.error('WebRTC error', e);
10641
+ logger$7.error('WebRTC error', e);
10587
10642
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10588
10643
  });
10589
10644
 
10645
+ this.client.on(this.client.REJECTED, session => {
10646
+ logger$7.info('WebRTC call rejected', session.id);
10647
+ const callSession = this._createCallSession(session);
10648
+ callSession.endTime = new Date();
10649
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10650
+ });
10651
+
10590
10652
  this.client.on(this.client.UNREGISTERED, () => {
10591
- logger$5.info('WebRTC unregistered');
10653
+ logger$7.info('WebRTC unregistered');
10592
10654
  this.eventEmitter.emit(ON_UNREGISTERED);
10593
10655
  });
10594
10656
 
10595
10657
  this.client.on(this.client.ON_DISCONNECTED, () => {
10596
- logger$5.info('WebRTC disconnected');
10597
- this.eventEmitter.emit(ON_DISCONNECTED$1);
10658
+ logger$7.info('WebRTC disconnected');
10659
+ this.eventEmitter.emit(ON_DISCONNECTED);
10598
10660
  });
10599
10661
 
10600
10662
  this.client.on(this.client.REGISTERED, () => {
10601
- logger$5.info('WebRTC registered', {
10663
+ logger$7.info('WebRTC registered', {
10602
10664
  shouldSendReinvite: this.shouldSendReinvite,
10603
10665
  state: this.currentSipSession ? this.currentSipSession.state : null,
10604
10666
  currentSipSession: !!this.currentSipSession,
@@ -10619,19 +10681,19 @@ class WebRTCPhone extends Emitter {
10619
10681
  // Send reinvite with iceRestart
10620
10682
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10621
10683
  } catch (e) {
10622
- logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10684
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10623
10685
  }
10624
10686
  }
10625
10687
  });
10626
10688
 
10627
10689
  this.client.on(this.client.CONNECTED, () => {
10628
- logger$5.info('WebRTC client connected');
10690
+ logger$7.info('WebRTC client connected');
10629
10691
 
10630
10692
  this.stopHeartbeat();
10631
10693
  });
10632
10694
 
10633
10695
  this.client.on(this.client.DISCONNECTED, () => {
10634
- logger$5.info('WebRTC client disconnected');
10696
+ logger$7.info('WebRTC client disconnected');
10635
10697
 
10636
10698
  this.eventEmitter.emit(ON_UNREGISTERED);
10637
10699
 
@@ -10645,7 +10707,7 @@ class WebRTCPhone extends Emitter {
10645
10707
  });
10646
10708
 
10647
10709
  this.client.on(this.client.ON_TRACK, (session, event) => {
10648
- this.eventEmitter.emit(ON_TRACK$1, session, event);
10710
+ this.eventEmitter.emit(ON_TRACK, session, event);
10649
10711
  });
10650
10712
 
10651
10713
  this.client.on('onVideoInputChange', stream => {
@@ -10660,7 +10722,7 @@ class WebRTCPhone extends Emitter {
10660
10722
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10661
10723
  const callSession = this.getCallSession(this.getSipSessionId(session));
10662
10724
 
10663
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10725
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10664
10726
  });
10665
10727
 
10666
10728
  // Used when upgrading directly in screenshare mode
@@ -10669,7 +10731,7 @@ class WebRTCPhone extends Emitter {
10669
10731
  const localStream = this.client.getLocalStream(sipSessionId);
10670
10732
  const callSession = this.callSessions[sipSessionId];
10671
10733
 
10672
- logger$5.info('Updrading directly in screensharing mode', {
10734
+ logger$7.info('Updrading directly in screensharing mode', {
10673
10735
  sipSessionId,
10674
10736
  tracks: localStream ? localStream.getTracks() : null,
10675
10737
  });
@@ -10799,6 +10861,7 @@ class WebRTCPhone extends Emitter {
10799
10861
  const number = identity ? identity.uri._normal.user : null;
10800
10862
  const { state } = sipSession || {};
10801
10863
  const sessionId = this.getSipSessionId(sipSession);
10864
+ fromSession = fromSession || this.callSessions[sessionId];
10802
10865
 
10803
10866
  const callSession = new CallSession({
10804
10867
  callId: fromSession && fromSession.callId,
@@ -10806,6 +10869,8 @@ class WebRTCPhone extends Emitter {
10806
10869
  sipStatus: state,
10807
10870
  displayName: identity ? identity.displayName || number : number,
10808
10871
  startTime: fromSession ? fromSession.startTime : new Date(),
10872
+ creationTime: fromSession ? fromSession.creationTime : null,
10873
+ endTime: fromSession ? fromSession.endTime : null,
10809
10874
  answered: state === SessionState.Established,
10810
10875
  paused: this.client.isCallHeld(sipSession),
10811
10876
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10816,6 +10881,7 @@ class WebRTCPhone extends Emitter {
10816
10881
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10817
10882
  recording: fromSession ? fromSession.isRecording() : false,
10818
10883
  recordingPaused: false, // @TODO
10884
+ sipSession,
10819
10885
  ...extra,
10820
10886
  });
10821
10887
 
@@ -10844,11 +10910,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10844
10910
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10845
10911
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10846
10912
  ON_CALL_FAILED: ON_CALL_FAILED,
10913
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10847
10914
  ON_CALL_ENDED: ON_CALL_ENDED,
10848
10915
  ON_CALL_ENDING: ON_CALL_ENDING,
10849
10916
  ON_MESSAGE: ON_MESSAGE,
10850
- ON_REINVITE: ON_REINVITE$1,
10851
- ON_TRACK: ON_TRACK$1,
10917
+ ON_REINVITE: ON_REINVITE,
10918
+ ON_TRACK: ON_TRACK,
10852
10919
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10853
10920
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10854
10921
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10863,13 +10930,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10863
10930
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10864
10931
  ON_CALL_ERROR: ON_CALL_ERROR,
10865
10932
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10866
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10933
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10867
10934
  ON_CHAT: ON_CHAT,
10868
10935
  ON_SIGNAL: ON_SIGNAL,
10869
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10936
+ ON_DISCONNECTED: ON_DISCONNECTED,
10870
10937
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10871
10938
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10872
- events: events$1,
10939
+ events: events,
10873
10940
  'default': WebRTCPhone
10874
10941
  });
10875
10942
 
@@ -11040,11 +11107,11 @@ var wazoWebsocket = {
11040
11107
  resolve();
11041
11108
  };
11042
11109
 
11043
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
11110
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
11044
11111
  handleError(`Connection error : ${error}`);
11045
11112
  });
11046
11113
 
11047
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
11114
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
11048
11115
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
11049
11116
  client.setOnHeartbeatTimeout(() => {
11050
11117
  handleError('No response to heartbeat');
@@ -11145,7 +11212,7 @@ var webrtc = {
11145
11212
  }),
11146
11213
  };
11147
11214
 
11148
- const parseCandidate$1 = line => {
11215
+ const parseCandidate = line => {
11149
11216
  let parts;
11150
11217
  // Parse both variants.
11151
11218
  if (line.indexOf('a=candidate:') === 0) {
@@ -11236,7 +11303,7 @@ var SymmetricNat = {
11236
11303
  }
11237
11304
 
11238
11305
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
11239
- const cand = parseCandidate$1(e.candidate.candidate);
11306
+ const cand = parseCandidate(e.candidate.candidate);
11240
11307
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
11241
11308
  candidates[cand.relatedPort].push(cand.port);
11242
11309
  } else if (!e.candidate) {
@@ -11304,7 +11371,7 @@ var iceIpv4 = {
11304
11371
  const rawCandidate = e.candidate.candidate;
11305
11372
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
11306
11373
  hasSrflxOrRelay = true;
11307
- const candidate = parseCandidate$1(e.candidate.candidate);
11374
+ const candidate = parseCandidate(e.candidate.candidate);
11308
11375
  ips.push(candidate.ip);
11309
11376
  }
11310
11377
  } else if (!e.candidate) {
@@ -11474,7 +11541,7 @@ const getCallableNumber = (number , country ) => {
11474
11541
  class InvalidSubscription extends Error {}
11475
11542
  class InvalidAuthorization extends Error {}
11476
11543
 
11477
- const logger$7 = IssueReporter$1.loggerFor('simple-auth');
11544
+ const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11478
11545
 
11479
11546
  class Auth {
11480
11547
 
@@ -11509,7 +11576,7 @@ class Auth {
11509
11576
  setApiClientId(this.clientId);
11510
11577
  setRefreshExpiration(this.expiration);
11511
11578
  setOnRefreshToken((token , session ) => {
11512
- logger$7.info('on refresh token done', { token });
11579
+ logger$5.info('on refresh token done', { token });
11513
11580
  setApiToken(token);
11514
11581
  Wazo.Websocket.updateToken(token);
11515
11582
 
@@ -11554,7 +11621,7 @@ class Auth {
11554
11621
  const rawSession = await getApiClient().auth.authenticate(token);
11555
11622
  return this._onAuthenticated(rawSession);
11556
11623
  } catch (e) {
11557
- logger$7.error('on validate token error', e);
11624
+ logger$5.error('on validate token error', e);
11558
11625
  console.warn(e);
11559
11626
  return false;
11560
11627
  }
@@ -11910,7 +11977,7 @@ class AdHocAPIConference {
11910
11977
 
11911
11978
  //
11912
11979
 
11913
- const logger$8 = IssueReporter$1.loggerFor('simple-phone');
11980
+ const logger$4 = IssueReporter$1.loggerFor('simple-phone');
11914
11981
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
11915
11982
  const protocolLogger = IssueReporter$1.loggerFor('sip');
11916
11983
 
@@ -12017,7 +12084,7 @@ class Phone extends Emitter {
12017
12084
  async disconnect() {
12018
12085
  if (this.phone) {
12019
12086
  if (this.phone.hasAnActiveCall()) {
12020
- logger$8.info('hangup call on disconnect');
12087
+ logger$4.info('hangup call on disconnect');
12021
12088
  // $FlowFixMe
12022
12089
  await this.phone.hangup();
12023
12090
  }
@@ -12040,13 +12107,13 @@ class Phone extends Emitter {
12040
12107
  }
12041
12108
 
12042
12109
  async hangup(callSession ) {
12043
- logger$8.info('hangup via simple phone', { callId: callSession.getId() });
12110
+ logger$4.info('hangup via simple phone', { callId: callSession.getId() });
12044
12111
 
12045
12112
  return this.phone && this.phone.hangup(callSession);
12046
12113
  }
12047
12114
 
12048
12115
  async accept(callSession , cameraEnabled ) {
12049
- logger$8.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
12116
+ logger$4.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
12050
12117
 
12051
12118
  return this.phone && this.phone.accept(callSession, cameraEnabled);
12052
12119
  }
@@ -12085,7 +12152,7 @@ class Phone extends Emitter {
12085
12152
  muteViaAPI(callSession ) {
12086
12153
  if (callSession && callSession.callId) {
12087
12154
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
12088
- logger$8.error('Mute via API, error', e);
12155
+ logger$4.error('Mute via API, error', e);
12089
12156
  });
12090
12157
  }
12091
12158
  }
@@ -12093,7 +12160,7 @@ class Phone extends Emitter {
12093
12160
  unmuteViaAPI(callSession ) {
12094
12161
  if (callSession && callSession.callId) {
12095
12162
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
12096
- logger$8.error('Unmute via API, error', e);
12163
+ logger$4.error('Unmute via API, error', e);
12097
12164
  });
12098
12165
  }
12099
12166
  }
@@ -12201,7 +12268,7 @@ class Phone extends Emitter {
12201
12268
 
12202
12269
  // @Deprecated
12203
12270
  getLocalMediaStream(callSession ) {
12204
- logger$8.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12271
+ logger$4.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12205
12272
 
12206
12273
  return this.phone && this.phone.getLocalStream(callSession);
12207
12274
  }
@@ -12224,20 +12291,20 @@ class Phone extends Emitter {
12224
12291
 
12225
12292
  // @Deprecated
12226
12293
  getRemoteStreamForCall(callSession ) {
12227
- logger$8.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12294
+ logger$4.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12228
12295
  return this.getRemoteStream(callSession);
12229
12296
  }
12230
12297
 
12231
12298
  // Returns remote streams directly from the peerConnection
12232
12299
  // @Deprecated
12233
12300
  getRemoteStreamsForCall(callSession ) {
12234
- logger$8.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12301
+ logger$4.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12235
12302
  return this.getLocalStream(callSession);
12236
12303
  }
12237
12304
 
12238
12305
  // @Deprecated
12239
12306
  getRemoteVideoStreamForCall(callSession ) {
12240
- logger$8.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12307
+ logger$4.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12241
12308
 
12242
12309
  return this.getRemoteVideoStream(callSession);
12243
12310
  }
@@ -12292,13 +12359,13 @@ class Phone extends Emitter {
12292
12359
 
12293
12360
  checkSfu() {
12294
12361
  if (!this.hasSfu()) {
12295
- throw new Error('Sorry your user is not configured to support video conference');
12362
+ throw new SFUNotAvailableError();
12296
12363
  }
12297
12364
  }
12298
12365
 
12299
12366
  _transferEvents() {
12300
12367
  this.unbind();
12301
- [...events, ...transportEvents].forEach(event => {
12368
+ [...events$1, ...transportEvents].forEach(event => {
12302
12369
  this.client.on(event, (...args) =>
12303
12370
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
12304
12371
  });
@@ -12320,10 +12387,10 @@ var Phone$1 = global.wazoTelephonyInstance;
12320
12387
 
12321
12388
  //
12322
12389
 
12323
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
12324
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
12390
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
12391
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
12325
12392
 
12326
- const logger$9 = IssueReporter$1.loggerFor('simple-ws-client');
12393
+ const logger$3 = IssueReporter$1.loggerFor('simple-ws-client');
12327
12394
 
12328
12395
  class Websocket extends Emitter {
12329
12396
 
@@ -12337,9 +12404,9 @@ class Websocket extends Emitter {
12337
12404
  // $FlowFixMe
12338
12405
  this[key] = OTHER_EVENTS[key];
12339
12406
  });
12340
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
12407
+ Object.keys(SOCKET_EVENTS).forEach(key => {
12341
12408
  // $FlowFixMe
12342
- this[key] = SOCKET_EVENTS$1[key];
12409
+ this[key] = SOCKET_EVENTS[key];
12343
12410
  });
12344
12411
  this.eventLists = WebSocketClient.eventLists;
12345
12412
 
@@ -12347,7 +12414,7 @@ class Websocket extends Emitter {
12347
12414
  }
12348
12415
 
12349
12416
  open(host , session ) {
12350
- logger$9.info('open simple WebSocket', { host, token: session.token });
12417
+ logger$3.info('open simple WebSocket', { host, token: session.token });
12351
12418
  this.ws = new WebSocketClient(
12352
12419
  {
12353
12420
  host,
@@ -12375,7 +12442,7 @@ class Websocket extends Emitter {
12375
12442
  }
12376
12443
 
12377
12444
  updateToken(token ) {
12378
- logger$9.info('update token via simple Websocket', { token, ws: !!this.ws });
12445
+ logger$3.info('update token via simple Websocket', { token, ws: !!this.ws });
12379
12446
 
12380
12447
  if (!this.ws) {
12381
12448
  return;
@@ -12403,7 +12470,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
12403
12470
 
12404
12471
  //
12405
12472
 
12406
- const logger$a = IssueReporter$1.loggerFor('room');
12473
+ const logger$2 = IssueReporter$1.loggerFor('room');
12407
12474
 
12408
12475
  class Participant extends Emitter {
12409
12476
 
@@ -12525,7 +12592,7 @@ class Participant extends Emitter {
12525
12592
  }
12526
12593
 
12527
12594
  onTalking(isTalking ) {
12528
- logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12595
+ logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12529
12596
  this.isTalking = isTalking;
12530
12597
  // you may notice we're not broadcasting: since all participants are getting this info
12531
12598
  // directly from asterisk, there's no need to do so
@@ -12628,7 +12695,7 @@ class Participant extends Emitter {
12628
12695
  }
12629
12696
 
12630
12697
  updateStatus(status , broadcast = true) {
12631
- logger$a.info('updating participant status', { name: this.name, status });
12698
+ logger$2.info('updating participant status', { name: this.name, status });
12632
12699
 
12633
12700
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
12634
12701
  if (status.audioMuted) {
@@ -12676,7 +12743,7 @@ class Participant extends Emitter {
12676
12743
 
12677
12744
  broadcastStatus(inboundStatus = null) {
12678
12745
  const status = inboundStatus || this.getStatus();
12679
- logger$a.info('broadcasting participant status', { callId: this.callId, status });
12746
+ logger$2.info('broadcasting participant status', { callId: this.callId, status });
12680
12747
 
12681
12748
  this.room.sendSignal({
12682
12749
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -12712,9 +12779,9 @@ class LocalParticipant extends Participant {
12712
12779
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12713
12780
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12714
12781
 
12715
- const logger$b = IssueReporter$1.loggerFor('sdk-room');
12782
+ const logger$1 = IssueReporter$1.loggerFor('sdk-room');
12716
12783
 
12717
- class Room$1 extends Emitter {
12784
+ class Room extends Emitter {
12718
12785
 
12719
12786
 
12720
12787
 
@@ -12772,7 +12839,7 @@ class Room$1 extends Emitter {
12772
12839
  extra = {},
12773
12840
  ) {
12774
12841
  super();
12775
- logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
12842
+ logger$1.info('room initialized', { callId, extension, sourceId, meetingUuid });
12776
12843
 
12777
12844
  // Represents the room callSession
12778
12845
  this.callSession = callSession;
@@ -12838,7 +12905,7 @@ class Room$1 extends Emitter {
12838
12905
  * @returns {Promise<Room>}
12839
12906
  */
12840
12907
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
12841
- logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
12908
+ logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
12842
12909
 
12843
12910
  if (!room) {
12844
12911
  await Wazo.Phone.connect();
@@ -12851,7 +12918,7 @@ class Room$1 extends Emitter {
12851
12918
 
12852
12919
  // Call_created is triggered before call_accepted, so we have to listen for it here.
12853
12920
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
12854
- logger$b.info('room call received via WS', { callId: data.call_id });
12921
+ logger$1.info('room call received via WS', { callId: data.call_id });
12855
12922
  if (room) {
12856
12923
  room.setCallId(data.call_id);
12857
12924
  }
@@ -12859,7 +12926,7 @@ class Room$1 extends Emitter {
12859
12926
 
12860
12927
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
12861
12928
  // eslint-disable-next-line no-param-reassign
12862
- room = new Room$1(callSession, extension, null, null, extra);
12929
+ room = new Room(callSession, extension, null, null, extra);
12863
12930
 
12864
12931
  // Wait for the call to be accepted
12865
12932
  await new Promise((resolve, reject) => {
@@ -12880,7 +12947,7 @@ class Room$1 extends Emitter {
12880
12947
  // Retrieve conference
12881
12948
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
12882
12949
 
12883
- logger$b.info('connected to room', {
12950
+ logger$1.info('connected to room', {
12884
12951
  sourceId: conference ? conference.sourceId : null,
12885
12952
  name: conference ? conference.name : null,
12886
12953
  });
@@ -12890,7 +12957,7 @@ class Room$1 extends Emitter {
12890
12957
  room.setName(conference.name);
12891
12958
  }
12892
12959
  } else if (meeting) {
12893
- logger$b.info('Already connected to meeting', {
12960
+ logger$1.info('Already connected to meeting', {
12894
12961
  uuid: meeting.uuid,
12895
12962
  name: meeting.name,
12896
12963
  });
@@ -12903,13 +12970,13 @@ class Room$1 extends Emitter {
12903
12970
  }
12904
12971
 
12905
12972
  static disconnect() {
12906
- logger$b.info('static disconnection to room');
12973
+ logger$1.info('static disconnection to room');
12907
12974
 
12908
12975
  Wazo.Phone.disconnect();
12909
12976
  }
12910
12977
 
12911
12978
  async disconnect() {
12912
- logger$b.info('disconnection to room called');
12979
+ logger$1.info('disconnection to room called');
12913
12980
 
12914
12981
  await Wazo.Phone.hangup(this.callSession);
12915
12982
  this.callSession = null;
@@ -12929,19 +12996,19 @@ class Room$1 extends Emitter {
12929
12996
  }
12930
12997
 
12931
12998
  setSourceId(sourceId ) {
12932
- logger$b.info('set room source id', { sourceId });
12999
+ logger$1.info('set room source id', { sourceId });
12933
13000
 
12934
13001
  this.sourceId = sourceId;
12935
13002
  }
12936
13003
 
12937
13004
  setMeetingUuid(meetingUuid ) {
12938
- logger$b.info('set meeting uuid', { meetingUuid });
13005
+ logger$1.info('set meeting uuid', { meetingUuid });
12939
13006
 
12940
13007
  this.meetingUuid = meetingUuid;
12941
13008
  }
12942
13009
 
12943
13010
  setCallId(callId ) {
12944
- logger$b.info('set room call id', { callId });
13011
+ logger$1.info('set room call id', { callId });
12945
13012
 
12946
13013
  if (callId) {
12947
13014
  this.callId = callId;
@@ -12949,7 +13016,7 @@ class Room$1 extends Emitter {
12949
13016
  }
12950
13017
 
12951
13018
  setName(name ) {
12952
- logger$b.info('set room name', { name });
13019
+ logger$1.info('set room name', { name });
12953
13020
 
12954
13021
  this.name = name;
12955
13022
  }
@@ -12968,7 +13035,7 @@ class Room$1 extends Emitter {
12968
13035
  }
12969
13036
 
12970
13037
  async startScreenSharing(constraints ) {
12971
- logger$b.info('start room screen sharing', { constraints });
13038
+ logger$1.info('start room screen sharing', { constraints });
12972
13039
 
12973
13040
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
12974
13041
  if (!screensharingStream) {
@@ -12982,7 +13049,7 @@ class Room$1 extends Emitter {
12982
13049
  }
12983
13050
 
12984
13051
  async stopScreenSharing(restoreLocalStream = true) {
12985
- logger$b.info('stop room screen sharing');
13052
+ logger$1.info('stop room screen sharing');
12986
13053
 
12987
13054
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
12988
13055
 
@@ -12994,7 +13061,7 @@ class Room$1 extends Emitter {
12994
13061
  }
12995
13062
 
12996
13063
  turnCameraOff() {
12997
- logger$b.info('turn room camera off');
13064
+ logger$1.info('turn room camera off');
12998
13065
 
12999
13066
  Wazo.Phone.turnCameraOff(this.callSession);
13000
13067
 
@@ -13004,7 +13071,7 @@ class Room$1 extends Emitter {
13004
13071
  }
13005
13072
 
13006
13073
  turnCameraOn() {
13007
- logger$b.info('turn room camera on');
13074
+ logger$1.info('turn room camera on');
13008
13075
 
13009
13076
  Wazo.Phone.turnCameraOn(this.callSession);
13010
13077
 
@@ -13014,7 +13081,7 @@ class Room$1 extends Emitter {
13014
13081
  }
13015
13082
 
13016
13083
  mute() {
13017
- logger$b.info('mute room');
13084
+ logger$1.info('mute room');
13018
13085
 
13019
13086
  Wazo.Phone.mute(this.callSession);
13020
13087
 
@@ -13022,7 +13089,7 @@ class Room$1 extends Emitter {
13022
13089
  }
13023
13090
 
13024
13091
  unmute() {
13025
- logger$b.info('unmute room');
13092
+ logger$1.info('unmute room');
13026
13093
 
13027
13094
  Wazo.Phone.unmute(this.callSession);
13028
13095
 
@@ -13042,7 +13109,7 @@ class Room$1 extends Emitter {
13042
13109
  }
13043
13110
 
13044
13111
  hold() {
13045
- logger$b.info('hold room');
13112
+ logger$1.info('hold room');
13046
13113
 
13047
13114
  Wazo.Phone.hold(this.callSession, true);
13048
13115
 
@@ -13052,7 +13119,7 @@ class Room$1 extends Emitter {
13052
13119
  }
13053
13120
 
13054
13121
  async resume() {
13055
- logger$b.info('resume room');
13122
+ logger$1.info('resume room');
13056
13123
 
13057
13124
  const newStream = await Wazo.Phone.resume(this.callSession, true);
13058
13125
 
@@ -13080,13 +13147,13 @@ class Room$1 extends Emitter {
13080
13147
  }
13081
13148
 
13082
13149
  sendDTMF(tone ) {
13083
- logger$b.info('send room DTMF', { tone });
13150
+ logger$1.info('send room DTMF', { tone });
13084
13151
 
13085
13152
  Wazo.Phone.sendDTMF(tone, this.callSession);
13086
13153
  }
13087
13154
 
13088
13155
  async sendReinvite(newConstraints = null) {
13089
- logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13156
+ logger$1.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13090
13157
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
13091
13158
 
13092
13159
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13145,7 +13212,7 @@ class Room$1 extends Emitter {
13145
13212
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13146
13213
 
13147
13214
  this.on(this.ON_AUDIO_STREAM, stream => {
13148
- logger$b.info('on room audio stream');
13215
+ logger$1.info('on room audio stream');
13149
13216
 
13150
13217
  this.audioStream = stream;
13151
13218
  if (!this.roomAudioElement) {
@@ -13158,7 +13225,7 @@ class Room$1 extends Emitter {
13158
13225
  });
13159
13226
 
13160
13227
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13161
- logger$b.info('on room video stream', { streamId });
13228
+ logger$1.info('on room video stream', { streamId });
13162
13229
 
13163
13230
  this._mapMsid(sipSession.body.body);
13164
13231
 
@@ -13173,7 +13240,7 @@ class Room$1 extends Emitter {
13173
13240
  });
13174
13241
 
13175
13242
  this.on(this.ON_REMOVE_STREAM, stream => {
13176
- logger$b.info('on room remove stream');
13243
+ logger$1.info('on room remove stream');
13177
13244
 
13178
13245
  const participant = this.participants.find(someParticipant =>
13179
13246
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13305,7 +13372,7 @@ class Room$1 extends Emitter {
13305
13372
  const requester = this._getParticipantFromCallId(origin.callId);
13306
13373
  if (requester) {
13307
13374
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13308
- logger$b.info('trigger room requester status', { origin });
13375
+ logger$1.info('trigger room requester status', { origin });
13309
13376
  requester.triggerUpdate('REQUESTER_UPDATE');
13310
13377
  }
13311
13378
  break;
@@ -13336,24 +13403,24 @@ class Room$1 extends Emitter {
13336
13403
 
13337
13404
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13338
13405
  if (participant.user_uuid === session.uuid) {
13339
- logger$b.info('room current user joined');
13406
+ logger$1.info('room current user joined');
13340
13407
 
13341
13408
  // Retrieve participants via an API calls
13342
13409
  const conferenceId = this.sourceId || payload.data.conference_id;
13343
13410
  let response;
13344
13411
  try {
13345
13412
  if (this.meetingUuid) {
13346
- logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13413
+ logger$1.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13347
13414
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13348
13415
  } else {
13349
- logger$b.info('fetching conference participants', { conferenceId });
13416
+ logger$1.info('fetching conference participants', { conferenceId });
13350
13417
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13351
13418
  }
13352
13419
  } catch (e) {
13353
- logger$b.error('room participants fetching, error', e);
13420
+ logger$1.error('room participants fetching, error', e);
13354
13421
  }
13355
13422
  if (response) {
13356
- logger$b.info('conference participants fetched', { nb: response.items.length });
13423
+ logger$1.info('conference participants fetched', { nb: response.items.length });
13357
13424
  participants = response.items.map(item => {
13358
13425
  const isMe = item.call_id === this.callId;
13359
13426
 
@@ -13380,7 +13447,7 @@ class Room$1 extends Emitter {
13380
13447
  ? new Wazo.RemoteParticipant(this, participant)
13381
13448
  : null;
13382
13449
 
13383
- logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13450
+ logger$1.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13384
13451
 
13385
13452
  if (remoteParticipant) {
13386
13453
  this.participants.push(remoteParticipant);
@@ -13545,12 +13612,12 @@ class Room$1 extends Emitter {
13545
13612
 
13546
13613
  //
13547
13614
 
13548
- const logger$c = IssueReporter$1.loggerFor('sdk-sip-room');
13615
+ const logger = IssueReporter$1.loggerFor('sdk-sip-room');
13549
13616
 
13550
- class SipRoom extends Room$1 {
13617
+ class SipRoom extends Room {
13551
13618
 
13552
13619
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
13553
- logger$c.info('connecting to sip room', { extension, audioOnly, room: !!room });
13620
+ logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
13554
13621
 
13555
13622
  if (!room) {
13556
13623
  await Wazo.Phone.connect();
@@ -13566,7 +13633,7 @@ class SipRoom extends Room$1 {
13566
13633
  room.setCallId(room.callSession.call.id);
13567
13634
  }
13568
13635
 
13569
- logger$c.info('connected to room', {
13636
+ logger.info('connected to room', {
13570
13637
  extension: room.extension,
13571
13638
  });
13572
13639
 
@@ -13574,7 +13641,7 @@ class SipRoom extends Room$1 {
13574
13641
  }
13575
13642
 
13576
13643
  mute() {
13577
- logger$c.info('mute sip room');
13644
+ logger.info('mute sip room');
13578
13645
 
13579
13646
  Wazo.Phone.mute(this.callSession, false);
13580
13647
 
@@ -13582,7 +13649,7 @@ class SipRoom extends Room$1 {
13582
13649
  }
13583
13650
 
13584
13651
  unmute() {
13585
- logger$c.info('unmute sip room');
13652
+ logger.info('unmute sip room');
13586
13653
 
13587
13654
  Wazo.Phone.unmute(this.callSession, false);
13588
13655
 
@@ -13795,7 +13862,7 @@ const Wazo = {
13795
13862
  Auth: Auth$1,
13796
13863
  Phone: Phone$1,
13797
13864
  Websocket: Websocket$1,
13798
- Room: Room$1,
13865
+ Room,
13799
13866
  SipRoom,
13800
13867
  RemoteParticipant,
13801
13868
  LocalParticipant,
@@ -13828,7 +13895,7 @@ const Wazo = {
13828
13895
  Session,
13829
13896
  Voicemail,
13830
13897
  Relocation,
13831
- ConferenceRoom: Room,
13898
+ ConferenceRoom: Room$1,
13832
13899
  CallSession,
13833
13900
  IndirectTransfer,
13834
13901
  SwitchboardCall,
@@ -13853,6 +13920,7 @@ const Wazo = {
13853
13920
  InvalidSubscription,
13854
13921
  InvalidAuthorization,
13855
13922
  CanceledCallError,
13923
+ SFUNotAvailableError,
13856
13924
  };
13857
13925
 
13858
13926
  if (window) {
@@ -13895,6 +13963,7 @@ var index = {
13895
13963
  WazoWebSocketClient: WebSocketClient,
13896
13964
  BadResponse,
13897
13965
  ServerError,
13966
+ SFUNotAvailableError,
13898
13967
  Call,
13899
13968
  CallSession,
13900
13969
  CTIPhone,
@@ -13914,13 +13983,13 @@ var index = {
13914
13983
  Session,
13915
13984
  Voicemail,
13916
13985
  Relocation,
13917
- Room,
13986
+ Room: Room$1,
13918
13987
  IssueReporter: IssueReporter$1,
13919
13988
  DebugDevice,
13920
13989
  PROFILE_STATE: STATE,
13921
13990
  FORWARD_KEYS,
13922
13991
  LINE_STATE,
13923
- SOCKET_EVENTS,
13992
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
13924
13993
  Wazo,
13925
13994
  WebRTCPhone,
13926
13995
  Meeting,