@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/lib/index.js CHANGED
@@ -471,11 +471,11 @@ var IssueReporter$1 = new IssueReporter();
471
471
 
472
472
  const methods = ['head', 'get', 'post', 'put', 'delete'];
473
473
 
474
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
474
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
475
475
 
476
476
  // Use a function here to be able to mock it in tests
477
477
  const realFetch = () => {
478
- if (typeof document !== 'undefined') {
478
+ if (typeof document !== 'undefined' && window.fetch) {
479
479
  // Browser
480
480
  return window.fetch;
481
481
  }
@@ -610,7 +610,7 @@ class ApiRequester {
610
610
  };
611
611
 
612
612
  if (this.refreshTokenPromise) {
613
- logger.info('A token is already refreshing, waiting ...', { url });
613
+ logger$c.info('A token is already refreshing, waiting ...', { url });
614
614
  await this.refreshTokenPromise;
615
615
  }
616
616
 
@@ -630,7 +630,7 @@ class ApiRequester {
630
630
  return promise.then(async (err ) => {
631
631
  // Check if the token is still valid
632
632
  if (firstCall && this._checkTokenExpired(response, err)) {
633
- logger.warn('token expired', { error: err.reason });
633
+ logger$c.warn('token expired', { error: err.reason });
634
634
  // Replay the call after refreshing the token
635
635
  return this._replayWithNewToken(err, path, method, body, headers, parse);
636
636
  }
@@ -640,7 +640,7 @@ class ApiRequester {
640
640
  : exceptionClass.fromResponse(err, response.status);
641
641
 
642
642
  if (this.shouldLogErrors) {
643
- logger.error('API error', error);
643
+ logger$c.error('API error', error);
644
644
  }
645
645
 
646
646
  throw error;
@@ -650,7 +650,7 @@ class ApiRequester {
650
650
  return newParse(response, isJson);
651
651
  }).catch(error => {
652
652
  if (this.shouldLogErrors) {
653
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
653
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
654
654
  }
655
655
 
656
656
  throw error;
@@ -678,13 +678,13 @@ class ApiRequester {
678
678
  ) {
679
679
  const isTokenNotFound = this._isTokenNotFound(err);
680
680
  let newPath = path;
681
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
681
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
682
682
 
683
683
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
684
684
 
685
685
  return this.refreshTokenPromise.then(() => {
686
686
  this.refreshTokenPromise = null;
687
- logger.info('token refreshed', { isTokenNotFound });
687
+ logger$c.info('token refreshed', { isTokenNotFound });
688
688
  if (isTokenNotFound) {
689
689
  const pathParts = path.split('/');
690
690
  pathParts.pop();
@@ -1935,7 +1935,7 @@ class Contact {
1935
1935
  this[key] = old[key] || this[key];
1936
1936
  });
1937
1937
 
1938
- if (old.lineState && !this.lineState) {
1938
+ if (old.lineState) {
1939
1939
  this.lineState = old.lineState;
1940
1940
  }
1941
1941
 
@@ -3265,8 +3265,10 @@ var updateFrom = (instance , from ) => {
3265
3265
 
3266
3266
 
3267
3267
 
3268
+
3268
3269
 
3269
3270
 
3271
+
3270
3272
 
3271
3273
 
3272
3274
 
@@ -3283,6 +3285,7 @@ var updateFrom = (instance , from ) => {
3283
3285
 
3284
3286
 
3285
3287
 
3288
+
3286
3289
 
3287
3290
 
3288
3291
  class CallSession {
@@ -3302,8 +3305,12 @@ class CallSession {
3302
3305
 
3303
3306
 
3304
3307
 
3308
+
3309
+
3305
3310
 
3306
3311
 
3312
+
3313
+
3307
3314
 
3308
3315
 
3309
3316
 
@@ -3341,6 +3348,8 @@ class CallSession {
3341
3348
 
3342
3349
 
3343
3350
 
3351
+
3352
+
3344
3353
 
3345
3354
  constructor({
3346
3355
  answered,
@@ -3354,6 +3363,8 @@ class CallSession {
3354
3363
  paused,
3355
3364
  ringing,
3356
3365
  startTime,
3366
+ creationTime,
3367
+ endTime,
3357
3368
  cameraEnabled,
3358
3369
  dialedExtension,
3359
3370
  sipCallId,
@@ -3366,12 +3377,15 @@ class CallSession {
3366
3377
  recording,
3367
3378
  recordingPaused,
3368
3379
  videoRemotelyDowngraded,
3380
+ sipSession,
3369
3381
  } ) {
3370
3382
  this.callId = callId;
3371
3383
  this.sipCallId = sipCallId;
3372
3384
  this.displayName = displayName;
3373
3385
  this.number = number;
3386
+ this.creationTime = creationTime;
3374
3387
  this.startTime = startTime;
3388
+ this.endTime = endTime;
3375
3389
  this.isCaller = isCaller;
3376
3390
  this.answered = answered;
3377
3391
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3404,7 @@ class CallSession {
3390
3404
  this.recording = recording || false;
3391
3405
  this.recordingPaused = recordingPaused || false;
3392
3406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
+ this.sipSession = sipSession;
3393
3408
 
3394
3409
  // Useful to compare instead of instanceof with minified code
3395
3410
  this.type = 'CallSession';
@@ -4148,7 +4163,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4148
4163
 
4149
4164
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4150
4165
 
4151
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4166
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4152
4167
 
4153
4168
  class CTIPhone extends Emitter {
4154
4169
 
@@ -4161,7 +4176,7 @@ class CTIPhone extends Emitter {
4161
4176
 
4162
4177
  constructor(session , isMobile = false, callbackAllLines = false) {
4163
4178
  super();
4164
- logger$1.info('CTI Phone created');
4179
+ logger$b.info('CTI Phone created');
4165
4180
  this.session = session;
4166
4181
  this.isMobile = isMobile;
4167
4182
  this.callbackAllLines = callbackAllLines;
@@ -4222,7 +4237,7 @@ class CTIPhone extends Emitter {
4222
4237
  }
4223
4238
 
4224
4239
  async makeCall(number , line ) {
4225
- logger$1.info('make CTI call', { number });
4240
+ logger$b.info('make CTI call', { number });
4226
4241
 
4227
4242
  if (!number) {
4228
4243
  return null;
@@ -4245,7 +4260,7 @@ class CTIPhone extends Emitter {
4245
4260
  if (!callSession) {
4246
4261
  return Promise.resolve(null);
4247
4262
  }
4248
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4263
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4249
4264
 
4250
4265
  if (!this.currentCall) {
4251
4266
  this.currentCall = callSession.call;
@@ -4258,7 +4273,7 @@ class CTIPhone extends Emitter {
4258
4273
  if (!callSession) {
4259
4274
  return;
4260
4275
  }
4261
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4276
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4262
4277
 
4263
4278
  this.currentCall = undefined;
4264
4279
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4268,7 +4283,7 @@ class CTIPhone extends Emitter {
4268
4283
  if (!callSession) {
4269
4284
  return Promise.resolve(false);
4270
4285
  }
4271
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4286
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4272
4287
 
4273
4288
  try {
4274
4289
  await CallApi.cancelCall(callSession);
@@ -4279,7 +4294,7 @@ class CTIPhone extends Emitter {
4279
4294
  this.eventEmitter.emit('onCallEnded', callSession);
4280
4295
  return true;
4281
4296
  } catch (e) {
4282
- logger$1.error('hangup CTI call, error', e);
4297
+ logger$b.error('hangup CTI call, error', e);
4283
4298
 
4284
4299
  this.eventEmitter.emit('onCallFailed', callSession);
4285
4300
  return false;
@@ -4292,7 +4307,7 @@ class CTIPhone extends Emitter {
4292
4307
  if (!callSession) {
4293
4308
  return;
4294
4309
  }
4295
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4310
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4296
4311
 
4297
4312
  await CallApi.cancelCall(callSession);
4298
4313
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4302,7 +4317,7 @@ class CTIPhone extends Emitter {
4302
4317
  if (!callSession) {
4303
4318
  return;
4304
4319
  }
4305
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4320
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4306
4321
 
4307
4322
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4308
4323
  }
@@ -4315,19 +4330,19 @@ class CTIPhone extends Emitter {
4315
4330
  if (!callSession) {
4316
4331
  return;
4317
4332
  }
4318
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4333
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4319
4334
 
4320
4335
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4321
4336
  }
4322
4337
 
4323
4338
  async cancelCTIIndirectTransfer(transferId ) {
4324
- logger$1.info('cancel CTI transfer', { transferId });
4339
+ logger$b.info('cancel CTI transfer', { transferId });
4325
4340
 
4326
4341
  return CallApi.cancelCallTransfer(transferId);
4327
4342
  }
4328
4343
 
4329
4344
  async confirmCTIIndirectTransfer(transferId ) {
4330
- logger$1.info('confirm CTI transfer', { transferId });
4345
+ logger$b.info('confirm CTI transfer', { transferId });
4331
4346
 
4332
4347
  return CallApi.confirmCallTransfer(transferId);
4333
4348
  }
@@ -4336,19 +4351,19 @@ class CTIPhone extends Emitter {
4336
4351
  if (!callSession) {
4337
4352
  return;
4338
4353
  }
4339
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4354
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4340
4355
 
4341
4356
  return CallApi.sendDTMF(callSession.callId, digits);
4342
4357
  }
4343
4358
 
4344
4359
  onConnectionMade() {
4345
- logger$1.info('on CTI connection made');
4360
+ logger$b.info('on CTI connection made');
4346
4361
 
4347
4362
  this.eventEmitter.emit('onCallAccepted');
4348
4363
  }
4349
4364
 
4350
4365
  async close() {
4351
- logger$1.info('CTI close');
4366
+ logger$b.info('CTI close');
4352
4367
 
4353
4368
  return Promise.resolve();
4354
4369
  }
@@ -4357,7 +4372,7 @@ class CTIPhone extends Emitter {
4357
4372
  if (!callSession) {
4358
4373
  return;
4359
4374
  }
4360
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4375
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4361
4376
 
4362
4377
  return CallApi.hold(callSession.callId);
4363
4378
  }
@@ -4366,7 +4381,7 @@ class CTIPhone extends Emitter {
4366
4381
  if (!callSession) {
4367
4382
  return;
4368
4383
  }
4369
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4384
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4370
4385
 
4371
4386
  return CallApi.resume(callSession.callId);
4372
4387
  }
@@ -4375,7 +4390,7 @@ class CTIPhone extends Emitter {
4375
4390
  if (!callSession) {
4376
4391
  return;
4377
4392
  }
4378
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4393
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4379
4394
 
4380
4395
  return CallApi.mute(callSession.callId);
4381
4396
  }
@@ -4384,7 +4399,7 @@ class CTIPhone extends Emitter {
4384
4399
  if (!callSession) {
4385
4400
  return;
4386
4401
  }
4387
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4402
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4388
4403
 
4389
4404
  return CallApi.unmute(callSession.callId);
4390
4405
  }
@@ -5393,7 +5408,7 @@ const AGENTD_VERSION = '1.0';
5393
5408
  const WEBHOOKD_VERSION = '1.0';
5394
5409
  const AMID_VERSION = '1.0';
5395
5410
 
5396
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5411
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5397
5412
 
5398
5413
  class ApiClient {
5399
5414
 
@@ -5445,12 +5460,12 @@ class ApiClient {
5445
5460
  }
5446
5461
 
5447
5462
  async forceRefreshToken() {
5448
- logger$2.info('forcing refresh token, calling callback');
5463
+ logger$a.info('forcing refresh token, calling callback');
5449
5464
  return this.refreshTokenCallback();
5450
5465
  }
5451
5466
 
5452
5467
  async refreshTokenCallback() {
5453
- logger$2.info('refresh token callback called', {
5468
+ logger$a.info('refresh token callback called', {
5454
5469
  refreshToken: this.refreshToken,
5455
5470
  refreshBackend: this.refreshBackend,
5456
5471
  refreshExpiration: this.refreshExpiration,
@@ -5468,7 +5483,7 @@ class ApiClient {
5468
5483
  this.isMobile,
5469
5484
  );
5470
5485
 
5471
- logger$2.info('token refreshed', { token: session.token });
5486
+ logger$a.info('token refreshed', { token: session.token });
5472
5487
 
5473
5488
  if (this.onRefreshToken) {
5474
5489
  this.onRefreshToken(session.token, session);
@@ -5523,7 +5538,7 @@ class ApiClient {
5523
5538
 
5524
5539
  /* */
5525
5540
 
5526
- const parseCandidate = (candidate ) => {
5541
+ const parseCandidate$1 = (candidate ) => {
5527
5542
  if (!candidate) {
5528
5543
  return null;
5529
5544
  }
@@ -5635,11 +5650,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5635
5650
 
5636
5651
  // $FlowFixMe
5637
5652
  setRemoteSessionDescription(sessionDescription ) {
5638
- const result = super.setRemoteSessionDescription(sessionDescription);
5653
+ try {
5654
+ const result = super.setRemoteSessionDescription(sessionDescription);
5639
5655
 
5640
- this.eventEmitter.emit('setDescription', sessionDescription);
5656
+ this.eventEmitter.emit('setDescription', sessionDescription);
5641
5657
 
5642
- return result;
5658
+ return result;
5659
+ } catch (error) {
5660
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5661
+ throw error;
5662
+ }
5643
5663
  }
5644
5664
 
5645
5665
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -5677,7 +5697,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5677
5697
  this.peerConnectionDelegate.onicecandidate = event => {
5678
5698
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5679
5699
  if (event.candidate) {
5680
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5700
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5681
5701
  }
5682
5702
  };
5683
5703
 
@@ -6141,7 +6161,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6141
6161
  const SEND_STATS_DELAY = 5000;
6142
6162
 
6143
6163
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6144
- const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6164
+ const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6145
6165
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6146
6166
 
6147
6167
  // events
@@ -6155,14 +6175,14 @@ const TRANSPORT_ERROR = 'transportError';
6155
6175
  const MESSAGE = 'message';
6156
6176
  const ACCEPTED = 'accepted';
6157
6177
  const REJECTED = 'rejected';
6158
- const ON_TRACK = 'onTrack';
6159
- const ON_REINVITE = 'reinvite';
6178
+ const ON_TRACK$1 = 'onTrack';
6179
+ const ON_REINVITE$1 = 'reinvite';
6160
6180
  const ON_ERROR = 'onError';
6161
6181
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6162
- const ON_NETWORK_STATS = 'onNetworkStats';
6163
- const ON_DISCONNECTED = 'onDisconnected';
6182
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6183
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6164
6184
 
6165
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6185
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6166
6186
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6167
6187
  class CanceledCallError extends Error {}
6168
6188
 
@@ -6298,12 +6318,12 @@ class WebRTCClient extends Emitter {
6298
6318
  this.MESSAGE = MESSAGE;
6299
6319
  this.ACCEPTED = ACCEPTED;
6300
6320
  this.REJECTED = REJECTED;
6301
- this.ON_TRACK = ON_TRACK;
6302
- this.ON_REINVITE = ON_REINVITE;
6321
+ this.ON_TRACK = ON_TRACK$1;
6322
+ this.ON_REINVITE = ON_REINVITE$1;
6303
6323
  this.ON_ERROR = ON_ERROR;
6304
6324
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6305
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6306
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6325
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6326
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6307
6327
  }
6308
6328
 
6309
6329
  configureMedia(media ) {
@@ -6320,13 +6340,13 @@ class WebRTCClient extends Emitter {
6320
6340
 
6321
6341
  createUserAgent(configOverrides ) {
6322
6342
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6323
- logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6343
+ logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6324
6344
 
6325
6345
  webRTCConfiguration.delegate = {
6326
6346
  onConnect: this.onConnect.bind(this),
6327
6347
  onDisconnect: this.onDisconnect.bind(this),
6328
6348
  onInvite: (invitation ) => {
6329
- logger$3.info('sdk webrtc on invite', {
6349
+ logger$9.info('sdk webrtc on invite', {
6330
6350
  method: 'delegate.onInvite',
6331
6351
  id: invitation.id,
6332
6352
  remoteURI: invitation.remoteURI,
@@ -6369,7 +6389,7 @@ class WebRTCClient extends Emitter {
6369
6389
  }
6370
6390
 
6371
6391
  onConnect() {
6372
- logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6392
+ logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6373
6393
  this.eventEmitter.emit(CONNECTED);
6374
6394
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6375
6395
  this.registerer.waitingToggle(false);
@@ -6378,7 +6398,7 @@ class WebRTCClient extends Emitter {
6378
6398
  }
6379
6399
 
6380
6400
  async onDisconnect(error ) {
6381
- logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6401
+ logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6382
6402
  this.connectionPromise = null;
6383
6403
  // The UA will attempt to reconnect automatically when an error occurred
6384
6404
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6403,37 +6423,37 @@ class WebRTCClient extends Emitter {
6403
6423
  };
6404
6424
 
6405
6425
  if (this.skipRegister) {
6406
- logger$3.info('sdk webrtc skip register...', logInfo);
6426
+ logger$9.info('sdk webrtc skip register...', logInfo);
6407
6427
  return Promise.resolve();
6408
6428
  }
6409
6429
 
6410
- logger$3.info('sdk webrtc registering...', logInfo);
6430
+ logger$9.info('sdk webrtc registering...', logInfo);
6411
6431
 
6412
6432
  if (!this.userAgent) {
6413
- logger$3.info('sdk webrtc recreating User Agent');
6433
+ logger$9.info('sdk webrtc recreating User Agent');
6414
6434
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6415
6435
  }
6416
6436
  if (!this.userAgent || this.isRegistered()) {
6417
- logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6437
+ logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6418
6438
  return Promise.resolve();
6419
6439
  }
6420
6440
 
6421
6441
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6422
- logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6442
+ logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6423
6443
  return Promise.resolve();
6424
6444
  }
6425
6445
 
6426
6446
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6427
6447
 
6428
6448
  const onRegisterFailed = () => {
6429
- logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6449
+ logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6430
6450
  this.connectionPromise = null;
6431
6451
  if (this.registerer && this.registerer.waiting) {
6432
6452
  this.registerer.waitingToggle(false);
6433
6453
  }
6434
6454
 
6435
6455
  if (tries <= MAX_REGISTER_TRIES) {
6436
- logger$3.info('sdk webrtc registering, retrying...', { tries });
6456
+ logger$9.info('sdk webrtc registering, retrying...', { tries });
6437
6457
  setTimeout(() => this.register(tries + 1), 300);
6438
6458
  }
6439
6459
  };
@@ -6442,18 +6462,18 @@ class WebRTCClient extends Emitter {
6442
6462
  // Avoid race condition with the close method called just before register and setting userAgent to null
6443
6463
  // during the resolution of the primise.
6444
6464
  if (!this.userAgent) {
6445
- logger$3.info('sdk webrtc recreating User Agent after connection');
6465
+ logger$9.info('sdk webrtc recreating User Agent after connection');
6446
6466
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6447
6467
  }
6448
6468
 
6449
- logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6469
+ logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6450
6470
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6451
6471
  this.connectionPromise = null;
6452
6472
  this._monkeyPatchRegisterer(this.registerer);
6453
6473
 
6454
6474
  // Bind registerer events
6455
6475
  this.registerer.stateChange.addListener(newState => {
6456
- logger$3.info('sdk webrtc registering, state changed', { newState });
6476
+ logger$9.info('sdk webrtc registering, state changed', { newState });
6457
6477
 
6458
6478
  if (newState === registererState.RegistererState.Registered && this.registerer
6459
6479
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6466,7 +6486,7 @@ class WebRTCClient extends Emitter {
6466
6486
  const options = {
6467
6487
  requestDelegate: {
6468
6488
  onReject: response => {
6469
- logger$3.error('sdk webrtc registering, rejected', { response });
6489
+ logger$9.error('sdk webrtc registering, rejected', { response });
6470
6490
 
6471
6491
  onRegisterFailed();
6472
6492
  },
@@ -6474,13 +6494,13 @@ class WebRTCClient extends Emitter {
6474
6494
  };
6475
6495
 
6476
6496
  return this.registerer.register(options).catch((e) => {
6477
- logger$3.error('sdk webrtc registering, error', e);
6497
+ logger$9.error('sdk webrtc registering, error', e);
6478
6498
 
6479
6499
  this.eventEmitter.emit(REGISTRATION_FAILED);
6480
6500
  return e;
6481
6501
  });
6482
6502
  }).catch(error => {
6483
- logger$3.error('sdk webrtc registering, transport error', error);
6503
+ logger$9.error('sdk webrtc registering, transport error', error);
6484
6504
  onRegisterFailed();
6485
6505
  });
6486
6506
  }
@@ -6509,21 +6529,21 @@ class WebRTCClient extends Emitter {
6509
6529
  }
6510
6530
 
6511
6531
  unregister() {
6512
- logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6532
+ logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6513
6533
  if (!this.registerer) {
6514
6534
  return Promise.resolve();
6515
6535
  }
6516
6536
 
6517
6537
  try {
6518
6538
  return this.registerer.unregister().then(() => {
6519
- logger$3.info('sdk webrtc unregistered');
6539
+ logger$9.info('sdk webrtc unregistered');
6520
6540
  this._cleanupRegister();
6521
6541
  }).catch(e => {
6522
- logger$3.error('sdk webrtc unregistering, promise error', e);
6542
+ logger$9.error('sdk webrtc unregistering, promise error', e);
6523
6543
  this._cleanupRegister();
6524
6544
  });
6525
6545
  } catch (e) {
6526
- logger$3.error('sdk webrtc unregistering, error', e);
6546
+ logger$9.error('sdk webrtc unregistering, error', e);
6527
6547
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6528
6548
  // error when the registerer is in a bad state
6529
6549
  this._cleanupRegister();
@@ -6531,7 +6551,7 @@ class WebRTCClient extends Emitter {
6531
6551
  }
6532
6552
 
6533
6553
  stop() {
6534
- logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6554
+ logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6535
6555
  if (!this.userAgent) {
6536
6556
  return Promise.resolve();
6537
6557
  }
@@ -6539,12 +6559,12 @@ class WebRTCClient extends Emitter {
6539
6559
  return this.userAgent.stop().then(() => {
6540
6560
  return this._cleanupRegister();
6541
6561
  }).catch(e => {
6542
- logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6562
+ logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6543
6563
  });
6544
6564
  }
6545
6565
 
6546
6566
  call(number , enableVideo , audioOnly = false, conference = false) {
6547
- logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6567
+ logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6548
6568
  const inviterOptions = {
6549
6569
  sessionDescriptionHandlerOptionsReInvite: {
6550
6570
  conference,
@@ -6575,7 +6595,7 @@ class WebRTCClient extends Emitter {
6575
6595
  this._onAccepted(session, response.session, true);
6576
6596
  },
6577
6597
  onReject: (response ) => {
6578
- logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6598
+ logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6579
6599
  this._stopSendingStats(session);
6580
6600
  this.stopNetworkMonitoring(session);
6581
6601
 
@@ -6598,11 +6618,11 @@ class WebRTCClient extends Emitter {
6598
6618
  }
6599
6619
 
6600
6620
  answer(session , enableVideo ) {
6601
- logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6621
+ logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6602
6622
 
6603
6623
  if (!session || !session.accept) {
6604
6624
  const error = 'No session to answer, or not an invitation';
6605
- logger$3.warn(error);
6625
+ logger$9.warn(error);
6606
6626
  return Promise.reject(new Error(error));
6607
6627
  }
6608
6628
  const options = {
@@ -6612,15 +6632,15 @@ class WebRTCClient extends Emitter {
6612
6632
  return session.accept(options).then(() => {
6613
6633
  if (session.isCanceled) {
6614
6634
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6615
- logger$3.error(message, { id: session.id });
6635
+ logger$9.error(message, { id: session.id });
6616
6636
  this.onCallEnded(session);
6617
6637
 
6618
6638
  throw new CanceledCallError(message);
6619
6639
  }
6620
- logger$3.info('sdk webrtc answer, accepted.');
6640
+ logger$9.info('sdk webrtc answer, accepted.');
6621
6641
  this._onAccepted(session);
6622
6642
  }).catch(e => {
6623
- logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6643
+ logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6624
6644
 
6625
6645
  throw e;
6626
6646
  });
@@ -6628,7 +6648,7 @@ class WebRTCClient extends Emitter {
6628
6648
 
6629
6649
  hangup(session ) {
6630
6650
  const { state, id } = session;
6631
- logger$3.info('sdk webrtc hangup call', { id, state });
6651
+ logger$9.info('sdk webrtc hangup call', { id, state });
6632
6652
 
6633
6653
  try {
6634
6654
  this._stopSendingStats(session);
@@ -6657,7 +6677,7 @@ class WebRTCClient extends Emitter {
6657
6677
 
6658
6678
  return bye();
6659
6679
  } catch (error) {
6660
- logger$3.warn('sdk webrtc hangup, error', error);
6680
+ logger$9.warn('sdk webrtc hangup, error', error);
6661
6681
  }
6662
6682
 
6663
6683
  return null;
@@ -6675,7 +6695,7 @@ class WebRTCClient extends Emitter {
6675
6695
  // Fetch and emit an event at `interval` with session network stats
6676
6696
  startNetworkMonitoring(session , interval = 1000) {
6677
6697
  const sessionId = this.getSipSessionId(session);
6678
- logger$3.info('starting network inspection', { id: sessionId });
6698
+ logger$9.info('starting network inspection', { id: sessionId });
6679
6699
 
6680
6700
  this.sessionNetworkStats[sessionId] = [];
6681
6701
 
@@ -6685,7 +6705,7 @@ class WebRTCClient extends Emitter {
6685
6705
  stopNetworkMonitoring(session ) {
6686
6706
  const sessionId = this.getSipSessionId(session);
6687
6707
  const exists = sessionId in this.networkMonitoringInterval;
6688
- logger$3.info('stopping network inspection', { id: sessionId, exists });
6708
+ logger$9.info('stopping network inspection', { id: sessionId, exists });
6689
6709
 
6690
6710
  if (exists) {
6691
6711
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6695,17 +6715,17 @@ class WebRTCClient extends Emitter {
6695
6715
  }
6696
6716
 
6697
6717
  reject(session ) {
6698
- logger$3.info('sdk webrtc reject call', { id: session.id });
6718
+ logger$9.info('sdk webrtc reject call', { id: session.id });
6699
6719
 
6700
6720
  try {
6701
6721
  return session.reject ? session.reject() : session.cancel();
6702
6722
  } catch (e) {
6703
- logger$3.warn('Error when rejecting call', e.message, e.stack);
6723
+ logger$9.warn('Error when rejecting call', e.message, e.stack);
6704
6724
  }
6705
6725
  }
6706
6726
 
6707
6727
  async close() {
6708
- logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6728
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6709
6729
  this._cleanupMedia();
6710
6730
  this.connectionPromise = null;
6711
6731
 
@@ -6736,7 +6756,7 @@ class WebRTCClient extends Emitter {
6736
6756
  // eg: "INVITE not rejectable in state Completed"
6737
6757
  }
6738
6758
  this.userAgent = null;
6739
- logger$3.info('sdk webrtc client closed');
6759
+ logger$9.info('sdk webrtc client closed');
6740
6760
  }
6741
6761
 
6742
6762
  getNumber(session ) {
@@ -6749,13 +6769,13 @@ class WebRTCClient extends Emitter {
6749
6769
  }
6750
6770
 
6751
6771
  mute(session ) {
6752
- logger$3.info('sdk webrtc mute', { id: session.id });
6772
+ logger$9.info('sdk webrtc mute', { id: session.id });
6753
6773
 
6754
6774
  this._toggleAudio(session, true);
6755
6775
  }
6756
6776
 
6757
6777
  unmute(session ) {
6758
- logger$3.info('sdk webrtc unmute', { id: session.id });
6778
+ logger$9.info('sdk webrtc unmute', { id: session.id });
6759
6779
 
6760
6780
  this._toggleAudio(session, false);
6761
6781
  }
@@ -6795,13 +6815,13 @@ class WebRTCClient extends Emitter {
6795
6815
  }
6796
6816
 
6797
6817
  toggleCameraOn(session ) {
6798
- logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6818
+ logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6799
6819
 
6800
6820
  this._toggleVideo(session, false);
6801
6821
  }
6802
6822
 
6803
6823
  toggleCameraOff(session ) {
6804
- logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6824
+ logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6805
6825
 
6806
6826
  this._toggleVideo(session, true);
6807
6827
  }
@@ -6810,7 +6830,7 @@ class WebRTCClient extends Emitter {
6810
6830
  const sessionId = this.getSipSessionId(session);
6811
6831
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6812
6832
 
6813
- logger$3.info('sdk webrtc hold', {
6833
+ logger$9.info('sdk webrtc hold', {
6814
6834
  sessionId,
6815
6835
  keys: Object.keys(this.heldSessions),
6816
6836
  pendingReinvite: !!session.pendingReinvite,
@@ -6859,7 +6879,7 @@ class WebRTCClient extends Emitter {
6859
6879
  const sessionId = this.getSipSessionId(session);
6860
6880
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
6861
6881
 
6862
- logger$3.info('sdk webrtc unhold', {
6882
+ logger$9.info('sdk webrtc unhold', {
6863
6883
  sessionId,
6864
6884
  keys: Object.keys(this.heldSessions),
6865
6885
  pendingReinvite: !!session.pendingReinvite,
@@ -7007,7 +7027,7 @@ class WebRTCClient extends Emitter {
7007
7027
  if (!session.sessionDescriptionHandler) {
7008
7028
  return;
7009
7029
  }
7010
- logger$3.info('Sending DTMF', {
7030
+ logger$9.info('Sending DTMF', {
7011
7031
  id: this.getSipSessionId(session),
7012
7032
  tone,
7013
7033
  });
@@ -7023,7 +7043,7 @@ class WebRTCClient extends Emitter {
7023
7043
  transfer(session , target ) {
7024
7044
  this.hold(session);
7025
7045
 
7026
- logger$3.info('Transfering a session', {
7046
+ logger$9.info('Transfering a session', {
7027
7047
  id: this.getSipSessionId(session),
7028
7048
  target,
7029
7049
  });
@@ -7045,17 +7065,17 @@ class WebRTCClient extends Emitter {
7045
7065
  atxfer(session ) {
7046
7066
  this.hold(session);
7047
7067
 
7048
- logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7068
+ logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7049
7069
 
7050
7070
  const result = {
7051
7071
  newSession: null,
7052
7072
  init: async (target ) => {
7053
- logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7073
+ logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7054
7074
 
7055
7075
  result.newSession = await this.call(target);
7056
7076
  },
7057
7077
  complete: () => {
7058
- logger$3.info('webrtc transfer completed', {
7078
+ logger$9.info('webrtc transfer completed', {
7059
7079
  id: this.getSipSessionId(session),
7060
7080
  referId: this.getSipSessionId(result.newSession),
7061
7081
  });
@@ -7076,7 +7096,7 @@ class WebRTCClient extends Emitter {
7076
7096
  return;
7077
7097
  }
7078
7098
 
7079
- logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7099
+ logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7080
7100
 
7081
7101
  try {
7082
7102
  sipSession.message({
@@ -7118,7 +7138,7 @@ class WebRTCClient extends Emitter {
7118
7138
  }
7119
7139
 
7120
7140
  changeAudioOutputVolume(volume ) {
7121
- logger$3.info('Changing audio output volume', { volume });
7141
+ logger$9.info('Changing audio output volume', { volume });
7122
7142
 
7123
7143
  Object.values(this.audioElements).forEach(audioElement => {
7124
7144
  if (audioElement instanceof HTMLAudioElement) {
@@ -7130,7 +7150,7 @@ class WebRTCClient extends Emitter {
7130
7150
  }
7131
7151
 
7132
7152
  changeAudioOutputDevice(id ) {
7133
- logger$3.info('Changing audio output device', { id });
7153
+ logger$9.info('Changing audio output device', { id });
7134
7154
 
7135
7155
  Object.values(this.audioElements).forEach(audioElement => {
7136
7156
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7147,7 +7167,7 @@ class WebRTCClient extends Emitter {
7147
7167
 
7148
7168
  changeAudioInputDevice(id , session ) {
7149
7169
  const currentId = this.getAudioDeviceId();
7150
- logger$3.info('setting audio input device', { id, currentId, session: !!session });
7170
+ logger$9.info('setting audio input device', { id, currentId, session: !!session });
7151
7171
 
7152
7172
  if (id === currentId) {
7153
7173
  return null;
@@ -7193,7 +7213,7 @@ class WebRTCClient extends Emitter {
7193
7213
 
7194
7214
  setVideoInputDevice(id ) {
7195
7215
  const currentId = this.getVideoDeviceId();
7196
- logger$3.info('setting video input device', { id, currentId });
7216
+ logger$9.info('setting video input device', { id, currentId });
7197
7217
 
7198
7218
  if (id === currentId) {
7199
7219
  return null;
@@ -7218,7 +7238,7 @@ class WebRTCClient extends Emitter {
7218
7238
  const sessionId = this.getSipSessionId(session);
7219
7239
  const localStream = this.getLocalStream(sessionId);
7220
7240
 
7221
- logger$3.info('changing video input device', { id, sessionId });
7241
+ logger$9.info('changing video input device', { id, sessionId });
7222
7242
 
7223
7243
  // Release old video stream
7224
7244
  if (localStream) {
@@ -7286,7 +7306,7 @@ class WebRTCClient extends Emitter {
7286
7306
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7287
7307
  const desktop = newConstraints && newConstraints.desktop;
7288
7308
 
7289
- logger$3.info('Sending reinvite', {
7309
+ logger$9.info('Sending reinvite', {
7290
7310
  id: this.getSipSessionId(sipSession),
7291
7311
  newConstraints,
7292
7312
  conference,
@@ -7324,7 +7344,7 @@ class WebRTCClient extends Emitter {
7324
7344
  sipSession.incomingInviteRequest.message.body = response.message.body;
7325
7345
  }
7326
7346
 
7327
- logger$3.info('on re-INVITE accepted', {
7347
+ logger$9.info('on re-INVITE accepted', {
7328
7348
  id: this.getSipSessionId(sipSession),
7329
7349
  wasMuted,
7330
7350
  shouldDoScreenSharing,
@@ -7342,7 +7362,7 @@ class WebRTCClient extends Emitter {
7342
7362
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7343
7363
  }
7344
7364
 
7345
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7365
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7346
7366
  },
7347
7367
  },
7348
7368
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7499,7 +7519,7 @@ class WebRTCClient extends Emitter {
7499
7519
  }
7500
7520
 
7501
7521
  startHeartbeat() {
7502
- logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7522
+ logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7503
7523
  if (!this.userAgent) {
7504
7524
  this.heartbeat.stop();
7505
7525
  return;
@@ -7512,7 +7532,7 @@ class WebRTCClient extends Emitter {
7512
7532
  }
7513
7533
 
7514
7534
  stopHeartbeat() {
7515
- logger$3.info('sdk webrtc stop heartbeat');
7535
+ logger$9.info('sdk webrtc stop heartbeat');
7516
7536
  this.heartbeat.stop();
7517
7537
  }
7518
7538
 
@@ -7533,7 +7553,7 @@ class WebRTCClient extends Emitter {
7533
7553
  }
7534
7554
 
7535
7555
  attemptReconnection() {
7536
- logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7556
+ logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7537
7557
  if (!this.userAgent) {
7538
7558
  return;
7539
7559
  }
@@ -7558,7 +7578,7 @@ class WebRTCClient extends Emitter {
7558
7578
  return;
7559
7579
  }
7560
7580
 
7561
- logger$3.info('setting local media stream', {
7581
+ logger$9.info('setting local media stream', {
7562
7582
  sipSessionId,
7563
7583
  tracks: newStream ? newStream.getTracks() : null,
7564
7584
  });
@@ -7575,7 +7595,7 @@ class WebRTCClient extends Emitter {
7575
7595
 
7576
7596
  const oldStream = this.getLocalStream(sipSessionId);
7577
7597
 
7578
- logger$3.info('updating local stream', {
7598
+ logger$9.info('updating local stream', {
7579
7599
  sipSessionId,
7580
7600
  oldStream: !!oldStream,
7581
7601
  tracks: newStream.getTracks(),
@@ -7595,7 +7615,7 @@ class WebRTCClient extends Emitter {
7595
7615
  const remoteStream = this.getRemoteStream(sessionId);
7596
7616
  const pc = this.getPeerConnection(sessionId);
7597
7617
 
7598
- logger$3.info('Updating remote stream', {
7618
+ logger$9.info('Updating remote stream', {
7599
7619
  sessionId,
7600
7620
  tracks: remoteStream ? remoteStream.getTracks() : null,
7601
7621
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7620,14 +7640,16 @@ class WebRTCClient extends Emitter {
7620
7640
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7621
7641
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7622
7642
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7643
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7623
7644
 
7624
- logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7645
+ logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7625
7646
 
7626
7647
  return {
7627
7648
  constraints: {
7628
7649
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7629
7650
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7630
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7651
+ video: screenSharing ? (isDesktop
7652
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7631
7653
  : this._getVideoConstraints(enableVideo),
7632
7654
  screen: screenSharing,
7633
7655
  desktop: isDesktop,
@@ -7670,7 +7692,7 @@ class WebRTCClient extends Emitter {
7670
7692
  }
7671
7693
 
7672
7694
  _onTransportError() {
7673
- logger$3.error('on transport error');
7695
+ logger$9.error('on transport error');
7674
7696
  this.eventEmitter.emit(TRANSPORT_ERROR);
7675
7697
  this.attemptReconnection();
7676
7698
  }
@@ -7679,7 +7701,7 @@ class WebRTCClient extends Emitter {
7679
7701
  const body = message && typeof message === 'object' ? message.data : message;
7680
7702
  if (body && body.indexOf('200 OK') !== -1) {
7681
7703
  if (this.hasHeartbeat()) {
7682
- logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7704
+ logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7683
7705
 
7684
7706
  this.heartbeat.onHeartbeat();
7685
7707
  if (this.heartbeatCb) {
@@ -7690,7 +7712,7 @@ class WebRTCClient extends Emitter {
7690
7712
  }
7691
7713
 
7692
7714
  async _onHeartbeatTimeout() {
7693
- logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7715
+ logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7694
7716
 
7695
7717
  if (this.heartbeatTimeoutCb) {
7696
7718
  this.heartbeatTimeoutCb();
@@ -7702,7 +7724,7 @@ class WebRTCClient extends Emitter {
7702
7724
  try {
7703
7725
  await this.userAgent.transport.disconnect();
7704
7726
  } catch (e) {
7705
- logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7727
+ logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7706
7728
  }
7707
7729
  }
7708
7730
 
@@ -7735,31 +7757,31 @@ class WebRTCClient extends Emitter {
7735
7757
  }
7736
7758
 
7737
7759
  _connectIfNeeded() {
7738
- logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7760
+ logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7739
7761
  if (!this.userAgent) {
7740
- logger$3.info('need to recreate User Agent');
7762
+ logger$9.info('need to recreate User Agent');
7741
7763
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7742
7764
  }
7743
7765
 
7744
7766
  if (this.isConnected()) {
7745
- logger$3.info('webrtc sdk, already connected');
7767
+ logger$9.info('webrtc sdk, already connected');
7746
7768
  return Promise.resolve();
7747
7769
  }
7748
7770
 
7749
7771
  if (this.isConnecting()) {
7750
- logger$3.info('webrtc sdk, already connecting...');
7772
+ logger$9.info('webrtc sdk, already connecting...');
7751
7773
 
7752
7774
  this.connectionPromise = this.userAgent.transport.connectPromise;
7753
7775
  return this.connectionPromise;
7754
7776
  }
7755
7777
 
7756
7778
  if (this.connectionPromise) {
7757
- logger$3.info('webrtc sdk, connection promise connecting...');
7779
+ logger$9.info('webrtc sdk, connection promise connecting...');
7758
7780
  // $FlowFixMe
7759
7781
  return this.connectionPromise;
7760
7782
  }
7761
7783
 
7762
- logger$3.info('WebRTC UA needs to connect');
7784
+ logger$9.info('WebRTC UA needs to connect');
7763
7785
 
7764
7786
  // Force UA to reconnect
7765
7787
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -7884,7 +7906,7 @@ class WebRTCClient extends Emitter {
7884
7906
 
7885
7907
  sdh.peerConnectionDelegate = {
7886
7908
  onicecandidateerror: (error ) => {
7887
- logger$3.error('on icecandidate error', {
7909
+ logger$9.error('on icecandidate error', {
7888
7910
  address: error.address,
7889
7911
  port: error.port,
7890
7912
  errorCode: error.errorCode,
@@ -7913,7 +7935,7 @@ class WebRTCClient extends Emitter {
7913
7935
  updatedNumber = session.assertedIdentity.uri.normal.user;
7914
7936
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
7915
7937
  }
7916
- logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7938
+ logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
7917
7939
 
7918
7940
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
7919
7941
 
@@ -7929,12 +7951,12 @@ class WebRTCClient extends Emitter {
7929
7951
 
7930
7952
  this._setupMedias(session);
7931
7953
 
7932
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7954
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
7933
7955
  };
7934
7956
  }
7935
7957
 
7936
7958
  _onAccepted(session , sessionDialog , withEvent = true) {
7937
- logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7959
+ logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
7938
7960
 
7939
7961
  this.storeSipSession(session);
7940
7962
 
@@ -7946,14 +7968,14 @@ class WebRTCClient extends Emitter {
7946
7968
  const onTrack = (event ) => {
7947
7969
  const isAudioOnly = this._isAudioOnly(session);
7948
7970
  const { kind, label, readyState, id, muted } = event.track;
7949
- logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7971
+ logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
7950
7972
 
7951
7973
  // Stop video track in audio only mode
7952
7974
  if (isAudioOnly && kind === 'video') {
7953
7975
  event.track.stop();
7954
7976
  }
7955
7977
 
7956
- this.eventEmitter.emit(ON_TRACK, session, event);
7978
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
7957
7979
  };
7958
7980
 
7959
7981
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -7962,12 +7984,14 @@ class WebRTCClient extends Emitter {
7962
7984
 
7963
7985
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
7964
7986
 
7965
- pc.oniceconnectionstatechange = () => {
7966
- logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
7967
- if (pc.iceConnectionState === 'disconnected') {
7968
- this.eventEmitter.emit(ON_DISCONNECTED);
7969
- }
7970
- };
7987
+ if (pc) {
7988
+ pc.oniceconnectionstatechange = () => {
7989
+ logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
7990
+ if (pc.iceConnectionState === 'disconnected') {
7991
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
7992
+ }
7993
+ };
7994
+ }
7971
7995
 
7972
7996
  if (withEvent) {
7973
7997
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8136,10 +8160,10 @@ class WebRTCClient extends Emitter {
8136
8160
 
8137
8161
  _stopSendingStats(session ) {
8138
8162
  const sessionId = this.getSipSessionId(session);
8139
- logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8163
+ logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8140
8164
 
8141
8165
  if (sessionId in this.statsIntervals) {
8142
- logger$3.trace('Stop sending stats for call', { sessionId });
8166
+ logger$9.trace('Stop sending stats for call', { sessionId });
8143
8167
  this.statsIntervals[sessionId]();
8144
8168
  delete this.statsIntervals[sessionId];
8145
8169
  }
@@ -8155,7 +8179,7 @@ class WebRTCClient extends Emitter {
8155
8179
  try {
8156
8180
  await this.userAgent.transport.disconnect();
8157
8181
  } catch (e) {
8158
- logger$3.error('WebRTC transport disconnect, error', e);
8182
+ logger$9.error('WebRTC transport disconnect, error', e);
8159
8183
  }
8160
8184
  }
8161
8185
  }
@@ -8177,13 +8201,17 @@ class WebRTCClient extends Emitter {
8177
8201
  const nbStats = this.sessionNetworkStats[sessionId].length;
8178
8202
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8179
8203
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8204
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8180
8205
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8181
8206
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8207
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8182
8208
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8183
8209
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8184
8210
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8185
- let audioBytesSent = 0;
8186
- let audioBytesReceived = 0;
8211
+ let audioBytesSent = 0; // content + header
8212
+ let audioBytesReceived = 0; // content + header
8213
+ let audioContentSent = 0; // useful to detect blank call
8214
+ let audioContentReceived = 0;
8187
8215
  let videoBytesSent = 0;
8188
8216
  let videoBytesReceived = 0;
8189
8217
  let transportSent = 0;
@@ -8193,6 +8221,7 @@ class WebRTCClient extends Emitter {
8193
8221
  stats.forEach(report => {
8194
8222
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8195
8223
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8224
+ audioContentSent += Number(report.bytesSent);
8196
8225
  }
8197
8226
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8198
8227
  audioBytesSent += Number(report.bytesSent);
@@ -8204,6 +8233,7 @@ class WebRTCClient extends Emitter {
8204
8233
  packetsLost += Number(report.packetsLost);
8205
8234
  networkStats.packetsReceived = Number(report.packetsReceived);
8206
8235
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8236
+ audioContentReceived += Number(report.bytesReceived);
8207
8237
  }
8208
8238
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8209
8239
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8232,10 +8262,17 @@ class WebRTCClient extends Emitter {
8232
8262
  });
8233
8263
 
8234
8264
  networkStats.packetsLost = packetsLost;
8265
+
8235
8266
  networkStats.totalAudioBytesSent = audioBytesSent;
8236
8267
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8237
8268
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8238
8269
  networkStats.audioBytesReceived = audioBytesReceived;
8270
+
8271
+ networkStats.totalAudioContentSent = audioContentSent;
8272
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8273
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8274
+ networkStats.audioContentReceived = audioContentReceived;
8275
+
8239
8276
  networkStats.totalVideoBytesSent = videoBytesSent;
8240
8277
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8241
8278
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8249,7 +8286,7 @@ class WebRTCClient extends Emitter {
8249
8286
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8250
8287
  + networkStats.transportSent;
8251
8288
 
8252
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8289
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8253
8290
  this.sessionNetworkStats[sessionId].push(networkStats);
8254
8291
  }
8255
8292
 
@@ -8257,7 +8294,7 @@ class WebRTCClient extends Emitter {
8257
8294
 
8258
8295
  //
8259
8296
 
8260
- const SOCKET_EVENTS = {
8297
+ const SOCKET_EVENTS$1 = {
8261
8298
  ON_OPEN: 'onopen',
8262
8299
  ON_MESSAGE: 'onmessage',
8263
8300
  ON_ERROR: 'onerror',
@@ -8353,7 +8390,7 @@ const BLACKLIST_EVENTS = [
8353
8390
  ];
8354
8391
 
8355
8392
  const HEARTBEAT_ENGINE_VERSION = '20.09';
8356
- const logger$4 = IssueReporter$1.loggerFor('wazo-ws');
8393
+ const logger$8 = IssueReporter$1.loggerFor('wazo-ws');
8357
8394
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
8358
8395
 
8359
8396
  class WebSocketClient extends Emitter {
@@ -8402,24 +8439,24 @@ class WebSocketClient extends Emitter {
8402
8439
  }
8403
8440
 
8404
8441
  connect() {
8405
- logger$4.info('connect method started', { host: this.host, token: this.token });
8442
+ logger$8.info('connect method started', { host: this.host, token: this.token });
8406
8443
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
8407
8444
  if (this.options.binaryType) {
8408
8445
  this.socket.binaryType = this.options.binaryType;
8409
8446
  }
8410
8447
 
8411
8448
  this.socket.onopen = () => {
8412
- logger$4.info('on Wazo WS open', { method: 'connect', host: this.host });
8413
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
8449
+ logger$8.info('on Wazo WS open', { method: 'connect', host: this.host });
8450
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
8414
8451
  };
8415
8452
 
8416
8453
  this.socket.onerror = event => {
8417
- logger$4.error('on Wazo WS error', event.target);
8418
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
8454
+ logger$8.error('on Wazo WS error', event.target);
8455
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
8419
8456
  };
8420
8457
 
8421
8458
  this.socket.onmessage = (event ) => {
8422
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
8459
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
8423
8460
 
8424
8461
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
8425
8462
  let { name } = message;
@@ -8444,7 +8481,7 @@ class WebSocketClient extends Emitter {
8444
8481
 
8445
8482
  this.socket.onclose = event => {
8446
8483
  // Can't be converted to JSON (circular structure)
8447
- logger$4.info('on Wazo WS close', {
8484
+ logger$8.info('on Wazo WS close', {
8448
8485
  reason: event.reason,
8449
8486
  code: event.code,
8450
8487
  readyState: event.target.readyState,
@@ -8452,22 +8489,22 @@ class WebSocketClient extends Emitter {
8452
8489
  token: this.token,
8453
8490
  });
8454
8491
  this.initialized = false;
8455
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
8492
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
8456
8493
 
8457
8494
  switch (event.code) {
8458
8495
  case 4002:
8459
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
8496
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
8460
8497
  break;
8461
8498
  }
8462
8499
  };
8463
8500
 
8464
8501
  this.socket.onerror = event => {
8465
- logger$4.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8502
+ logger$8.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
8466
8503
  };
8467
8504
  }
8468
8505
 
8469
8506
  close(force = false) {
8470
- logger$4.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8507
+ logger$8.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
8471
8508
 
8472
8509
  if (!this.socket) {
8473
8510
  return;
@@ -8485,7 +8522,7 @@ class WebSocketClient extends Emitter {
8485
8522
 
8486
8523
  updateToken(token ) {
8487
8524
  this.token = token;
8488
- logger$4.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8525
+ logger$8.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
8489
8526
 
8490
8527
  if (this.socket) {
8491
8528
  // If still connected, send the token to the WS
@@ -8503,7 +8540,7 @@ class WebSocketClient extends Emitter {
8503
8540
  }
8504
8541
 
8505
8542
  startHeartbeat() {
8506
- logger$4.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8543
+ logger$8.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
8507
8544
 
8508
8545
  if (!this.socket) {
8509
8546
  this.heartbeat.stop();
@@ -8517,7 +8554,7 @@ class WebSocketClient extends Emitter {
8517
8554
  }
8518
8555
 
8519
8556
  stopHeartbeat() {
8520
- logger$4.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8557
+ logger$8.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
8521
8558
 
8522
8559
  this.heartbeat.stop();
8523
8560
  }
@@ -8547,7 +8584,7 @@ class WebSocketClient extends Emitter {
8547
8584
  }
8548
8585
 
8549
8586
  reconnect(reason ) {
8550
- logger$4.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8587
+ logger$8.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
8551
8588
  if (!this.socket) {
8552
8589
  return;
8553
8590
  }
@@ -8572,7 +8609,7 @@ class WebSocketClient extends Emitter {
8572
8609
  break;
8573
8610
  case 'start':
8574
8611
  this.initialized = true;
8575
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
8612
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
8576
8613
  break;
8577
8614
  default:
8578
8615
  this.eventEmitter.emit('message', message);
@@ -8603,7 +8640,7 @@ class WebSocketClient extends Emitter {
8603
8640
  this.close();
8604
8641
  }
8605
8642
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
8606
- logger$4.log('Wazo WS url computed to reconnect', { url });
8643
+ logger$8.log('Wazo WS url computed to reconnect', { url });
8607
8644
 
8608
8645
  return url;
8609
8646
  }
@@ -8611,15 +8648,15 @@ class WebSocketClient extends Emitter {
8611
8648
  _onHeartbeat(message ) {
8612
8649
  if (message.payload === 'pong') {
8613
8650
  this.heartbeat.onHeartbeat();
8614
- logger$4.log('on heartbeat received from Wazo WS');
8651
+ logger$8.log('on heartbeat received from Wazo WS');
8615
8652
  }
8616
8653
  }
8617
8654
 
8618
8655
  async _onHeartbeatTimeout() {
8619
- logger$4.log('heartbeat timed out', { host: this.host, token: this.token });
8656
+ logger$8.log('heartbeat timed out', { host: this.host, token: this.token });
8620
8657
 
8621
8658
  this.close();
8622
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
8659
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
8623
8660
 
8624
8661
  if (this.onHeartBeatTimeout) {
8625
8662
  this.onHeartBeatTimeout();
@@ -8699,7 +8736,7 @@ WebSocketClient.eventLists = [
8699
8736
 
8700
8737
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8701
8738
  __proto__: null,
8702
- SOCKET_EVENTS: SOCKET_EVENTS,
8739
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
8703
8740
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
8704
8741
  FAVORITE_ADDED: FAVORITE_ADDED,
8705
8742
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -8770,6 +8807,14 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
8770
8807
  'default': WebSocketClient
8771
8808
  });
8772
8809
 
8810
+ /* */
8811
+ class SFUNotAvailableError extends Error {
8812
+ constructor(message = 'Sorry your user is not configured to support video conference') {
8813
+ super(message);
8814
+ this.name = 'SFUNotAvailableError';
8815
+ }
8816
+ }
8817
+
8773
8818
  var COUNTRIES = {
8774
8819
  BELGIUM: 'BE',
8775
8820
  CANADA: 'CA',
@@ -8932,7 +8977,7 @@ class NotificationOptions {
8932
8977
 
8933
8978
 
8934
8979
  // Represents a conference room, like `9000`.
8935
- class Room {
8980
+ class Room$1 {
8936
8981
 
8937
8982
 
8938
8983
 
@@ -8953,7 +8998,7 @@ class Room {
8953
8998
  }
8954
8999
 
8955
9000
  connect(callSession ) {
8956
- return new Room({ ...this, connectedCallSession: callSession });
9001
+ return new Room$1({ ...this, connectedCallSession: callSession });
8957
9002
  }
8958
9003
 
8959
9004
  has(callSession ) {
@@ -8962,7 +9007,7 @@ class Room {
8962
9007
 
8963
9008
  addParticipant(uuid , extension , talking = null) {
8964
9009
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
8965
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
9010
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
8966
9011
  }
8967
9012
 
8968
9013
  return this;
@@ -8981,7 +9026,7 @@ class Room {
8981
9026
  updatedParticipants.push(participant);
8982
9027
  }
8983
9028
 
8984
- return new Room({ ...this, participants: updatedParticipants });
9029
+ return new Room$1({ ...this, participants: updatedParticipants });
8985
9030
  }
8986
9031
 
8987
9032
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -8997,7 +9042,7 @@ class Room {
8997
9042
  updatedParticipants.push(participant);
8998
9043
  }
8999
9044
 
9000
- return new Room({ ...this, participants: updatedParticipants });
9045
+ return new Room$1({ ...this, participants: updatedParticipants });
9001
9046
  }
9002
9047
 
9003
9048
  hasCallWithId(id ) {
@@ -9005,18 +9050,18 @@ class Room {
9005
9050
  }
9006
9051
 
9007
9052
  disconnect() {
9008
- return new Room({ ...this, connectedCallSession: null });
9053
+ return new Room$1({ ...this, connectedCallSession: null });
9009
9054
  }
9010
9055
 
9011
9056
  removeParticipantWithUUID(uuid ) {
9012
- return new Room({
9057
+ return new Room$1({
9013
9058
  ...this,
9014
9059
  participants: this.participants.filter(participant => participant.uuid !== uuid),
9015
9060
  });
9016
9061
  }
9017
9062
 
9018
9063
  removeParticipantWithExtension(extension ) {
9019
- return new Room({
9064
+ return new Room$1({
9020
9065
  ...this,
9021
9066
  participants: this.participants.filter(participant => participant.extension !== extension),
9022
9067
  });
@@ -9027,7 +9072,7 @@ class Room {
9027
9072
  }
9028
9073
 
9029
9074
  static newFrom(room ) {
9030
- return newFrom(room, Room);
9075
+ return newFrom(room, Room$1);
9031
9076
  }
9032
9077
  }
9033
9078
 
@@ -9167,11 +9212,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
9167
9212
  const ON_CAMERA_RESUMED = 'onCameraResumed';
9168
9213
  const ON_CALL_CANCELED = 'onCallCanceled';
9169
9214
  const ON_CALL_FAILED = 'onCallFailed';
9215
+ const ON_CALL_REJECTED = 'onCallRejected';
9170
9216
  const ON_CALL_ENDED = 'onCallEnded';
9171
9217
  const ON_CALL_ENDING = 'onCallEnding';
9172
9218
  const ON_MESSAGE = 'onMessage';
9173
- const ON_REINVITE$1 = 'reinvite';
9174
- const ON_TRACK$1 = 'onTrack';
9219
+ const ON_REINVITE = 'reinvite';
9220
+ const ON_TRACK = 'onTrack';
9175
9221
  const ON_AUDIO_STREAM = 'onAudioStream';
9176
9222
  const ON_VIDEO_STREAM = 'onVideoStream';
9177
9223
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -9186,15 +9232,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
9186
9232
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
9187
9233
  const ON_CALL_ERROR = 'onCallError';
9188
9234
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
9189
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
9235
+ const ON_NETWORK_STATS = 'onNetworkStats';
9190
9236
  const ON_CHAT = 'phone/ON_CHAT';
9191
9237
  const ON_SIGNAL = 'phone/ON_SIGNAL';
9192
- const ON_DISCONNECTED$1 = 'onDisconnected';
9238
+ const ON_DISCONNECTED = 'onDisconnected';
9193
9239
 
9194
9240
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
9195
9241
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
9196
9242
 
9197
- const events$1 = [
9243
+ const events = [
9198
9244
  ON_USER_AGENT,
9199
9245
  ON_REGISTERED,
9200
9246
  ON_UNREGISTERED,
@@ -9211,9 +9257,10 @@ const events$1 = [
9211
9257
  ON_CAMERA_DISABLED,
9212
9258
  ON_CALL_FAILED,
9213
9259
  ON_CALL_ENDED,
9260
+ ON_CALL_REJECTED,
9214
9261
  ON_MESSAGE,
9215
- ON_REINVITE$1,
9216
- ON_TRACK$1,
9262
+ ON_REINVITE,
9263
+ ON_TRACK,
9217
9264
  ON_AUDIO_STREAM,
9218
9265
  ON_VIDEO_STREAM,
9219
9266
  ON_REMOVE_STREAM,
@@ -9228,11 +9275,11 @@ const events$1 = [
9228
9275
  ON_CALL_ERROR,
9229
9276
  ON_CHAT,
9230
9277
  ON_SIGNAL,
9231
- ON_NETWORK_STATS$1,
9232
- ON_DISCONNECTED$1,
9278
+ ON_NETWORK_STATS,
9279
+ ON_DISCONNECTED,
9233
9280
  ];
9234
9281
 
9235
- const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
9282
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
9236
9283
 
9237
9284
  class WebRTCPhone extends Emitter {
9238
9285
 
@@ -9305,7 +9352,7 @@ class WebRTCPhone extends Emitter {
9305
9352
  }).catch(error => {
9306
9353
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
9307
9354
  console.error('register error', error, error.message, error.stack);
9308
- logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
9355
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
9309
9356
  });
9310
9357
  }
9311
9358
 
@@ -9320,7 +9367,7 @@ class WebRTCPhone extends Emitter {
9320
9367
  if (!this.client) {
9321
9368
  return;
9322
9369
  }
9323
- logger$5.info('WebRTC phone stop');
9370
+ logger$7.info('WebRTC phone stop');
9324
9371
  this.client.stop();
9325
9372
  }
9326
9373
 
@@ -9335,11 +9382,12 @@ class WebRTCPhone extends Emitter {
9335
9382
  async sendReinvite(callSession , constraints = null, conference = false,
9336
9383
  audioOnly = false, iceRestart = false) {
9337
9384
  const sipSession = this.findSipSession(callSession);
9338
- logger$5.info('WebRTC phone - send reinvite', {
9385
+ logger$7.info('WebRTC phone - send reinvite', {
9339
9386
  sessionId: sipSession ? sipSession.id : null,
9340
9387
  constraints,
9341
9388
  audioOnly,
9342
9389
  conference,
9390
+ iceRestart,
9343
9391
  });
9344
9392
 
9345
9393
  if (!sipSession) {
@@ -9372,7 +9420,7 @@ class WebRTCPhone extends Emitter {
9372
9420
  }
9373
9421
 
9374
9422
  startHeartbeat() {
9375
- logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9423
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
9376
9424
  if (!this.client || this.client.hasHeartbeat()) {
9377
9425
  return;
9378
9426
  }
@@ -9381,7 +9429,7 @@ class WebRTCPhone extends Emitter {
9381
9429
  }
9382
9430
 
9383
9431
  stopHeartbeat() {
9384
- logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9432
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
9385
9433
  if (!this.client) {
9386
9434
  return;
9387
9435
  }
@@ -9398,7 +9446,7 @@ class WebRTCPhone extends Emitter {
9398
9446
  }
9399
9447
 
9400
9448
  reconnect() {
9401
- logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
9449
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
9402
9450
  if (!this.client) {
9403
9451
  return;
9404
9452
  }
@@ -9439,7 +9487,7 @@ class WebRTCPhone extends Emitter {
9439
9487
  return false;
9440
9488
  }
9441
9489
 
9442
- logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9490
+ logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9443
9491
 
9444
9492
  this.client.downgradeToAudio(sipSession);
9445
9493
 
@@ -9462,7 +9510,7 @@ class WebRTCPhone extends Emitter {
9462
9510
  return Promise.resolve(false);
9463
9511
  }
9464
9512
 
9465
- logger$5.info('Upgrade to video', {
9513
+ logger$7.info('Upgrade to video', {
9466
9514
  id: callSession ? callSession.getId() : null,
9467
9515
  constraints,
9468
9516
  isConference,
@@ -9502,7 +9550,7 @@ class WebRTCPhone extends Emitter {
9502
9550
 
9503
9551
  _sendReinviteMessage(callSession , isUpgrade ) {
9504
9552
  const sipSession = this.findSipSession(callSession);
9505
- logger$5.info('Sending reinvite message', {
9553
+ logger$7.info('Sending reinvite message', {
9506
9554
  id: callSession ? callSession.getId() : null,
9507
9555
  isUpgrade,
9508
9556
  });
@@ -9528,7 +9576,7 @@ class WebRTCPhone extends Emitter {
9528
9576
  // Monkey patch to know when canceled with the CANCEL message
9529
9577
  const onCancel = sipSession._onCancel.bind(sipSession);
9530
9578
  sipSession._onCancel = (message ) => {
9531
- logger$5.trace('on sip session canceled', { callId: message.callId });
9579
+ logger$7.trace('on sip session canceled', { callId: message.callId });
9532
9580
 
9533
9581
  onCancel(message);
9534
9582
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -9556,16 +9604,17 @@ class WebRTCPhone extends Emitter {
9556
9604
  this.audioOutputVolume,
9557
9605
  );
9558
9606
  case sessionState.SessionState.Terminating:
9559
- logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9607
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9560
9608
 
9561
9609
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9562
9610
 
9563
9611
  break;
9564
9612
  case sessionState.SessionState.Terminated: {
9565
- logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9613
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9566
9614
 
9567
9615
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9568
9616
  const callSession = this._createCallSession(sipSession);
9617
+ callSession.endTime = new Date();
9569
9618
  const wasCurrentSession = this._onCallTerminated(sipSession);
9570
9619
 
9571
9620
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9584,7 +9633,7 @@ class WebRTCPhone extends Emitter {
9584
9633
  const [stream] = event.streams;
9585
9634
  const kind = event && event.track && event.track.kind;
9586
9635
 
9587
- logger$5.info('on track stream called on the peer connection', {
9636
+ logger$7.info('on track stream called on the peer connection', {
9588
9637
  callId: this.getSipSessionId(sipSession),
9589
9638
  streamId: stream ? stream.id : null,
9590
9639
  tracks: stream ? stream.getTracks() : null,
@@ -9604,7 +9653,7 @@ class WebRTCPhone extends Emitter {
9604
9653
  };
9605
9654
 
9606
9655
  peerConnection.onremovestream = event => {
9607
- logger$5.info('on remove stream called on the peer connection', {
9656
+ logger$7.info('on remove stream called on the peer connection', {
9608
9657
  id: event.stream.id,
9609
9658
  tracks: event.stream.getTracks(),
9610
9659
  });
@@ -9614,7 +9663,7 @@ class WebRTCPhone extends Emitter {
9614
9663
  }
9615
9664
 
9616
9665
  async startScreenSharing(constraints , callSession ) {
9617
- logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9666
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9618
9667
 
9619
9668
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9620
9669
  if (!screenShareStream) {
@@ -9654,7 +9703,7 @@ class WebRTCPhone extends Emitter {
9654
9703
  return;
9655
9704
  }
9656
9705
 
9657
- logger$5.info('WebRTC phone - stop screen sharing', {
9706
+ logger$7.info('WebRTC phone - stop screen sharing', {
9658
9707
  restoreLocalStream,
9659
9708
  });
9660
9709
 
@@ -9710,7 +9759,7 @@ class WebRTCPhone extends Emitter {
9710
9759
  const pc = this.client.getPeerConnection(sipSessionId);
9711
9760
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9712
9761
 
9713
- logger$5.info('WebRTC phone - on screensharing', {
9762
+ logger$7.info('WebRTC phone - on screensharing', {
9714
9763
  hadVideo,
9715
9764
  id: this.getSipSessionId(sipSession),
9716
9765
  screenTrack,
@@ -9718,7 +9767,7 @@ class WebRTCPhone extends Emitter {
9718
9767
 
9719
9768
  if (screenTrack) {
9720
9769
  screenTrack.onended = () => {
9721
- logger$5.info('WebRTC phone - on screenshare ended', {
9770
+ logger$7.info('WebRTC phone - on screenshare ended', {
9722
9771
  hadVideo,
9723
9772
  id: this.getSipSessionId(sipSession),
9724
9773
  screenTrack,
@@ -9749,7 +9798,7 @@ class WebRTCPhone extends Emitter {
9749
9798
  }
9750
9799
 
9751
9800
  _onCallAccepted(sipSession , cameraEnabled ) {
9752
- logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9801
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9753
9802
 
9754
9803
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9755
9804
  this.currentSipSession = sipSession;
@@ -9767,7 +9816,7 @@ class WebRTCPhone extends Emitter {
9767
9816
  }
9768
9817
 
9769
9818
  changeAudioDevice(id ) {
9770
- logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9819
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9771
9820
  this.audioOutputDeviceId = id;
9772
9821
  this.client.changeAudioOutputDevice(id);
9773
9822
  }
@@ -9777,14 +9826,14 @@ class WebRTCPhone extends Emitter {
9777
9826
  }
9778
9827
 
9779
9828
  changeRingDevice(id ) {
9780
- logger$5.info('WebRTC phone - changing ring device', { id });
9829
+ logger$7.info('WebRTC phone - changing ring device', { id });
9781
9830
 
9782
9831
  this.audioRingDeviceId = id;
9783
9832
  }
9784
9833
 
9785
9834
  // volume is a value between 0 and 1
9786
9835
  changeAudioVolume(volume ) {
9787
- logger$5.info('WebRTC phone - changing audio volume', { volume });
9836
+ logger$7.info('WebRTC phone - changing audio volume', { volume });
9788
9837
 
9789
9838
  this.audioOutputVolume = volume;
9790
9839
  this.client.changeAudioOutputVolume(volume);
@@ -9792,32 +9841,33 @@ class WebRTCPhone extends Emitter {
9792
9841
 
9793
9842
  // volume is a value between 0 and 1
9794
9843
  changeRingVolume(volume ) {
9795
- logger$5.info('WebRTC phone - changing ring volume', { volume });
9844
+ logger$7.info('WebRTC phone - changing ring volume', { volume });
9796
9845
 
9797
9846
  this.audioRingVolume = volume;
9798
9847
  }
9799
9848
 
9800
9849
  changeAudioInputDevice(id ) {
9801
- logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9850
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9802
9851
 
9803
9852
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9804
9853
  }
9805
9854
 
9806
9855
  changeVideoInputDevice(id ) {
9807
- logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9856
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9808
9857
 
9809
9858
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9810
9859
  }
9811
9860
 
9812
9861
  changeSessionVideoInputDevice(id ) {
9813
- logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9862
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9814
9863
 
9815
9864
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9816
9865
  }
9817
9866
 
9818
9867
  _onCallTerminated(sipSession ) {
9819
- logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9868
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9820
9869
 
9870
+ const sipSessionId = this.getSipSessionId(sipSession);
9821
9871
  const callSession = this._createCallSession(sipSession);
9822
9872
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9823
9873
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9835,7 +9885,6 @@ class WebRTCPhone extends Emitter {
9835
9885
  }, 5);
9836
9886
  }
9837
9887
 
9838
- const sipSessionId = this.getSipSessionId(sipSession);
9839
9888
  if (sipSessionId) {
9840
9889
  this.removeIncomingSessions(sipSessionId);
9841
9890
  }
@@ -9850,7 +9899,7 @@ class WebRTCPhone extends Emitter {
9850
9899
  const hasIncomingCallSession = this.hasIncomingCallSession();
9851
9900
 
9852
9901
  // Re-trigger incoming call event for remaining incoming calls
9853
- logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9902
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9854
9903
  sipId: sipSession.id,
9855
9904
  shouldRetrigger,
9856
9905
  hasIncomingCallSession,
@@ -9941,37 +9990,37 @@ class WebRTCPhone extends Emitter {
9941
9990
 
9942
9991
  // Deprecated
9943
9992
  getLocalStreamForCall(callSession ) {
9944
- logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9993
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9945
9994
 
9946
9995
  return this.getLocalStream(callSession);
9947
9996
  }
9948
9997
 
9949
9998
  // Deprecated
9950
9999
  getRemoteStreamForCall(callSession ) {
9951
- logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
10000
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9952
10001
 
9953
10002
  return this.getRemoteVideoStream(callSession);
9954
10003
  }
9955
10004
 
9956
10005
  getRemoteStreamsForCall(callSession ) {
9957
- logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
10006
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9958
10007
 
9959
10008
  return this.getRemoteStream(callSession);
9960
10009
  }
9961
10010
 
9962
10011
  accept(callSession , cameraEnabled ) {
9963
- logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
10012
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9964
10013
  if (this.currentSipSession) {
9965
10014
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9966
10015
  }
9967
10016
 
9968
10017
  if (!callSession) {
9969
- logger$5.warn('no CallSession to accept.');
10018
+ logger$7.warn('no CallSession to accept.');
9970
10019
  return Promise.resolve(null);
9971
10020
  }
9972
10021
 
9973
10022
  if (callSession.getId() in this.acceptedSessions) {
9974
- logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
10023
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9975
10024
  return Promise.resolve(callSession.sipCallId);
9976
10025
  }
9977
10026
 
@@ -9983,24 +10032,24 @@ class WebRTCPhone extends Emitter {
9983
10032
  const sipSession = this.client.getSipSession(callSession.getId());
9984
10033
  if (sipSession) {
9985
10034
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9986
- logger$5.warn('Trying to answer a terminated sipSession.');
10035
+ logger$7.warn('Trying to answer a terminated sipSession.');
9987
10036
 
9988
10037
  return Promise.resolve(null);
9989
10038
  }
9990
10039
 
9991
- logger$5.info('accept call, session found', { sipId: sipSession.id });
10040
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
9992
10041
 
9993
10042
  // $FlowFixMe
9994
10043
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9995
10044
  return callSession.sipCallId;
9996
10045
  }).catch(e => {
9997
- logger$5.error(e);
10046
+ logger$7.error(e);
9998
10047
  this.endCurrentCall(callSession);
9999
10048
  throw e;
10000
10049
  });
10001
10050
  }
10002
10051
 
10003
- logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
10052
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
10004
10053
 
10005
10054
  return Promise.resolve(null);
10006
10055
  }
@@ -10010,7 +10059,7 @@ class WebRTCPhone extends Emitter {
10010
10059
  }
10011
10060
 
10012
10061
  async reject(callSession ) {
10013
- logger$5.info('reject WebRTC called', { id: callSession.getId() });
10062
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
10014
10063
 
10015
10064
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
10016
10065
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -10022,14 +10071,14 @@ class WebRTCPhone extends Emitter {
10022
10071
 
10023
10072
  const sipSession = this.findSipSession(callSession);
10024
10073
  if (sipSession) {
10025
- logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
10074
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
10026
10075
 
10027
10076
  this.client.hangup(sipSession);
10028
10077
  }
10029
10078
  }
10030
10079
 
10031
10080
  async ignore(callSession ) {
10032
- logger$5.info('WebRTC ignore', { id: callSession.getId() });
10081
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
10033
10082
 
10034
10083
  // kill the ring
10035
10084
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -10041,14 +10090,14 @@ class WebRTCPhone extends Emitter {
10041
10090
  const sipSession = this.findSipSession(callSession);
10042
10091
 
10043
10092
  if (sipSession) {
10044
- logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
10093
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
10045
10094
 
10046
10095
  return this.client.atxfer(sipSession);
10047
10096
  }
10048
10097
  }
10049
10098
 
10050
10099
  hold(callSession , withEvent = true, isConference = false) {
10051
- logger$5.info('WebRTC hold', { id: callSession.getId() });
10100
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
10052
10101
 
10053
10102
  const sipSession = this.findSipSession(callSession);
10054
10103
 
@@ -10063,18 +10112,18 @@ class WebRTCPhone extends Emitter {
10063
10112
  }
10064
10113
 
10065
10114
  resume(callSession , isConference = false, withEvent = true) {
10066
- logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
10115
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
10067
10116
 
10068
10117
  const sipSession = this.findSipSession(callSession);
10069
10118
  if (!sipSession) {
10070
10119
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
10071
10120
  }
10072
10121
 
10073
- logger$5.info('WebRTC resuming', { sipId: sipSession.id });
10122
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
10074
10123
 
10075
10124
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
10076
10125
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
10077
- logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
10126
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
10078
10127
  this.holdSipSession(this.currentSipSession, callSession);
10079
10128
  }
10080
10129
 
@@ -10099,7 +10148,7 @@ class WebRTCPhone extends Emitter {
10099
10148
  const sessionId = this.getSipSessionId(sipSession);
10100
10149
  const hasVideo = this.client.hasLocalVideo(sessionId);
10101
10150
 
10102
- logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10151
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
10103
10152
 
10104
10153
  // Stop screenshre if needed
10105
10154
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -10130,7 +10179,7 @@ class WebRTCPhone extends Emitter {
10130
10179
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
10131
10180
  }
10132
10181
  const sessionId = this.getSipSessionId(sipSession);
10133
- logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
10182
+ logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
10134
10183
 
10135
10184
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
10136
10185
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -10174,14 +10223,14 @@ class WebRTCPhone extends Emitter {
10174
10223
  }
10175
10224
 
10176
10225
  mute(callSession , withEvent = true) {
10177
- logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10226
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
10178
10227
 
10179
10228
  const sipSession = this.findSipSession(callSession);
10180
10229
  if (!sipSession) {
10181
10230
  return;
10182
10231
  }
10183
10232
 
10184
- logger$5.info('WebRTC muting', { sipId: sipSession.id });
10233
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
10185
10234
  this.client.mute(sipSession);
10186
10235
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
10187
10236
 
@@ -10195,14 +10244,14 @@ class WebRTCPhone extends Emitter {
10195
10244
  }
10196
10245
 
10197
10246
  unmute(callSession , withEvent = true) {
10198
- logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10247
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
10199
10248
 
10200
10249
  const sipSession = this.findSipSession(callSession);
10201
10250
  if (!sipSession) {
10202
10251
  return;
10203
10252
  }
10204
10253
 
10205
- logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
10254
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
10206
10255
  this.client.unmute(sipSession);
10207
10256
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
10208
10257
 
@@ -10229,7 +10278,7 @@ class WebRTCPhone extends Emitter {
10229
10278
  if (!sipSession) {
10230
10279
  return;
10231
10280
  }
10232
- logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
10281
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
10233
10282
 
10234
10283
  this.client.toggleCameraOn(sipSession);
10235
10284
 
@@ -10241,7 +10290,7 @@ class WebRTCPhone extends Emitter {
10241
10290
  if (!sipSession) {
10242
10291
  return;
10243
10292
  }
10244
- logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
10293
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
10245
10294
 
10246
10295
  this.client.toggleCameraOff(sipSession);
10247
10296
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -10253,7 +10302,7 @@ class WebRTCPhone extends Emitter {
10253
10302
  return;
10254
10303
  }
10255
10304
 
10256
- logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
10305
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
10257
10306
  this.client.sendDTMF(sipSession, tone);
10258
10307
  }
10259
10308
 
@@ -10261,7 +10310,7 @@ class WebRTCPhone extends Emitter {
10261
10310
  // @TODO: line is not used here
10262
10311
  async makeCall(number , line , cameraEnabled ,
10263
10312
  audioOnly = false, conference = false) {
10264
- logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
10313
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
10265
10314
  if (!number) {
10266
10315
  return Promise.resolve(null);
10267
10316
  }
@@ -10271,7 +10320,7 @@ class WebRTCPhone extends Emitter {
10271
10320
  }
10272
10321
  if (this.currentSipSession) {
10273
10322
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
10274
- logger$5.warn('Unable to hold current session when making another call', e);
10323
+ logger$7.warn('Unable to hold current session when making another call', e);
10275
10324
  });
10276
10325
  }
10277
10326
 
@@ -10281,10 +10330,11 @@ class WebRTCPhone extends Emitter {
10281
10330
  this._bindEvents(sipSession);
10282
10331
  } catch (error) {
10283
10332
  console.warn(error);
10284
- logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10333
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
10285
10334
  return Promise.resolve(null);
10286
10335
  }
10287
10336
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
10337
+ callSession.creationTime = new Date();
10288
10338
 
10289
10339
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
10290
10340
 
@@ -10309,7 +10359,7 @@ class WebRTCPhone extends Emitter {
10309
10359
  return;
10310
10360
  }
10311
10361
 
10312
- logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
10362
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
10313
10363
 
10314
10364
  this.client.transfer(sipSession, target);
10315
10365
  }
@@ -10318,7 +10368,7 @@ class WebRTCPhone extends Emitter {
10318
10368
  const sipSession = this.client.getSipSession(source.sipCallId);
10319
10369
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
10320
10370
 
10321
- logger$5.info('WebRTC indirect transfer', {
10371
+ logger$7.info('WebRTC indirect transfer', {
10322
10372
  sipId: sipSession ? sipSession.id : null,
10323
10373
  target: sipSessionTarget ? sipSessionTarget.id : null,
10324
10374
  });
@@ -10357,7 +10407,7 @@ class WebRTCPhone extends Emitter {
10357
10407
  return false;
10358
10408
  }
10359
10409
 
10360
- logger$5.info('WebRTC hangup', { sipId: sipSession.id });
10410
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
10361
10411
 
10362
10412
  const sipSessionId = this.getSipSessionId(sipSession);
10363
10413
 
@@ -10403,7 +10453,7 @@ class WebRTCPhone extends Emitter {
10403
10453
  endCurrentCall(callSession ) {
10404
10454
  const isCurrent = this.isCurrentCallSipSession(callSession);
10405
10455
 
10406
- logger$5.info('Ending current call', {
10456
+ logger$7.info('Ending current call', {
10407
10457
  id: callSession ? callSession.getId() : null,
10408
10458
  isCurrent,
10409
10459
  });
@@ -10427,7 +10477,7 @@ class WebRTCPhone extends Emitter {
10427
10477
  }
10428
10478
 
10429
10479
  async close() {
10430
- logger$5.info('WebRTC close');
10480
+ logger$7.info('WebRTC close');
10431
10481
 
10432
10482
  try {
10433
10483
  await Promise.race([
@@ -10435,7 +10485,7 @@ class WebRTCPhone extends Emitter {
10435
10485
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
10436
10486
  ]);
10437
10487
  } catch (e) {
10438
- logger$5.error('WebRTC close, unregister error', e);
10488
+ logger$7.error('WebRTC close, unregister error', e);
10439
10489
  }
10440
10490
 
10441
10491
  this.client.close();
@@ -10453,12 +10503,12 @@ class WebRTCPhone extends Emitter {
10453
10503
  }
10454
10504
 
10455
10505
  enableRinging() {
10456
- logger$5.info('WebRTC enable ringing');
10506
+ logger$7.info('WebRTC enable ringing');
10457
10507
  this.ringingEnabled = true;
10458
10508
  }
10459
10509
 
10460
10510
  disableRinging() {
10461
- logger$5.info('WebRTC disable ringing');
10511
+ logger$7.info('WebRTC disable ringing');
10462
10512
  this.ringingEnabled = false;
10463
10513
  }
10464
10514
 
@@ -10480,8 +10530,12 @@ class WebRTCPhone extends Emitter {
10480
10530
  }
10481
10531
 
10482
10532
  const sessionId = this.incomingSessions[0];
10533
+ const sipSession = this.client.getSipSession(sessionId);
10534
+ if (!sipSession) {
10535
+ return null;
10536
+ }
10483
10537
 
10484
- return this._createCallSession(this.client.getSipSession(sessionId));
10538
+ return this._createCallSession(sipSession);
10485
10539
  }
10486
10540
 
10487
10541
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10498,7 +10552,7 @@ class WebRTCPhone extends Emitter {
10498
10552
 
10499
10553
  // Deprecated
10500
10554
  getLocalMediaStream(callSession ) {
10501
- logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10555
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10502
10556
  return this.getLocalStream(callSession);
10503
10557
  }
10504
10558
 
@@ -10540,7 +10594,7 @@ class WebRTCPhone extends Emitter {
10540
10594
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10541
10595
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10542
10596
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10543
- logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10597
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10544
10598
 
10545
10599
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10546
10600
  this.incomingSessions.push(callSession.getId());
@@ -10559,11 +10613,12 @@ class WebRTCPhone extends Emitter {
10559
10613
  callSession);
10560
10614
  }
10561
10615
 
10616
+ callSession.creationTime = new Date();
10562
10617
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10563
10618
  });
10564
10619
 
10565
10620
  this.client.on(this.client.ON_REINVITE, (...args) => {
10566
- logger$5.info('WebRTC on reinvite', {
10621
+ logger$7.info('WebRTC on reinvite', {
10567
10622
  sessionId: args[0].id,
10568
10623
  inviteId: args[1].id,
10569
10624
  updatedCalleeName: args[2],
@@ -10583,7 +10638,7 @@ class WebRTCPhone extends Emitter {
10583
10638
  });
10584
10639
 
10585
10640
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10586
- logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10641
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10587
10642
 
10588
10643
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10589
10644
 
@@ -10594,22 +10649,29 @@ class WebRTCPhone extends Emitter {
10594
10649
  this.client.on('ended', () => {});
10595
10650
 
10596
10651
  this.client.on(this.client.ON_ERROR, e => {
10597
- logger$5.error('WebRTC error', e);
10652
+ logger$7.error('WebRTC error', e);
10598
10653
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10599
10654
  });
10600
10655
 
10656
+ this.client.on(this.client.REJECTED, session => {
10657
+ logger$7.info('WebRTC call rejected', session.id);
10658
+ const callSession = this._createCallSession(session);
10659
+ callSession.endTime = new Date();
10660
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10661
+ });
10662
+
10601
10663
  this.client.on(this.client.UNREGISTERED, () => {
10602
- logger$5.info('WebRTC unregistered');
10664
+ logger$7.info('WebRTC unregistered');
10603
10665
  this.eventEmitter.emit(ON_UNREGISTERED);
10604
10666
  });
10605
10667
 
10606
10668
  this.client.on(this.client.ON_DISCONNECTED, () => {
10607
- logger$5.info('WebRTC disconnected');
10608
- this.eventEmitter.emit(ON_DISCONNECTED$1);
10669
+ logger$7.info('WebRTC disconnected');
10670
+ this.eventEmitter.emit(ON_DISCONNECTED);
10609
10671
  });
10610
10672
 
10611
10673
  this.client.on(this.client.REGISTERED, () => {
10612
- logger$5.info('WebRTC registered', {
10674
+ logger$7.info('WebRTC registered', {
10613
10675
  shouldSendReinvite: this.shouldSendReinvite,
10614
10676
  state: this.currentSipSession ? this.currentSipSession.state : null,
10615
10677
  currentSipSession: !!this.currentSipSession,
@@ -10630,19 +10692,19 @@ class WebRTCPhone extends Emitter {
10630
10692
  // Send reinvite with iceRestart
10631
10693
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10632
10694
  } catch (e) {
10633
- logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10695
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10634
10696
  }
10635
10697
  }
10636
10698
  });
10637
10699
 
10638
10700
  this.client.on(this.client.CONNECTED, () => {
10639
- logger$5.info('WebRTC client connected');
10701
+ logger$7.info('WebRTC client connected');
10640
10702
 
10641
10703
  this.stopHeartbeat();
10642
10704
  });
10643
10705
 
10644
10706
  this.client.on(this.client.DISCONNECTED, () => {
10645
- logger$5.info('WebRTC client disconnected');
10707
+ logger$7.info('WebRTC client disconnected');
10646
10708
 
10647
10709
  this.eventEmitter.emit(ON_UNREGISTERED);
10648
10710
 
@@ -10656,7 +10718,7 @@ class WebRTCPhone extends Emitter {
10656
10718
  });
10657
10719
 
10658
10720
  this.client.on(this.client.ON_TRACK, (session, event) => {
10659
- this.eventEmitter.emit(ON_TRACK$1, session, event);
10721
+ this.eventEmitter.emit(ON_TRACK, session, event);
10660
10722
  });
10661
10723
 
10662
10724
  this.client.on('onVideoInputChange', stream => {
@@ -10671,7 +10733,7 @@ class WebRTCPhone extends Emitter {
10671
10733
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10672
10734
  const callSession = this.getCallSession(this.getSipSessionId(session));
10673
10735
 
10674
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10736
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10675
10737
  });
10676
10738
 
10677
10739
  // Used when upgrading directly in screenshare mode
@@ -10680,7 +10742,7 @@ class WebRTCPhone extends Emitter {
10680
10742
  const localStream = this.client.getLocalStream(sipSessionId);
10681
10743
  const callSession = this.callSessions[sipSessionId];
10682
10744
 
10683
- logger$5.info('Updrading directly in screensharing mode', {
10745
+ logger$7.info('Updrading directly in screensharing mode', {
10684
10746
  sipSessionId,
10685
10747
  tracks: localStream ? localStream.getTracks() : null,
10686
10748
  });
@@ -10810,6 +10872,7 @@ class WebRTCPhone extends Emitter {
10810
10872
  const number = identity ? identity.uri._normal.user : null;
10811
10873
  const { state } = sipSession || {};
10812
10874
  const sessionId = this.getSipSessionId(sipSession);
10875
+ fromSession = fromSession || this.callSessions[sessionId];
10813
10876
 
10814
10877
  const callSession = new CallSession({
10815
10878
  callId: fromSession && fromSession.callId,
@@ -10817,6 +10880,8 @@ class WebRTCPhone extends Emitter {
10817
10880
  sipStatus: state,
10818
10881
  displayName: identity ? identity.displayName || number : number,
10819
10882
  startTime: fromSession ? fromSession.startTime : new Date(),
10883
+ creationTime: fromSession ? fromSession.creationTime : null,
10884
+ endTime: fromSession ? fromSession.endTime : null,
10820
10885
  answered: state === sessionState.SessionState.Established,
10821
10886
  paused: this.client.isCallHeld(sipSession),
10822
10887
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10827,6 +10892,7 @@ class WebRTCPhone extends Emitter {
10827
10892
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10828
10893
  recording: fromSession ? fromSession.isRecording() : false,
10829
10894
  recordingPaused: false, // @TODO
10895
+ sipSession,
10830
10896
  ...extra,
10831
10897
  });
10832
10898
 
@@ -10855,11 +10921,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10855
10921
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10856
10922
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10857
10923
  ON_CALL_FAILED: ON_CALL_FAILED,
10924
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10858
10925
  ON_CALL_ENDED: ON_CALL_ENDED,
10859
10926
  ON_CALL_ENDING: ON_CALL_ENDING,
10860
10927
  ON_MESSAGE: ON_MESSAGE,
10861
- ON_REINVITE: ON_REINVITE$1,
10862
- ON_TRACK: ON_TRACK$1,
10928
+ ON_REINVITE: ON_REINVITE,
10929
+ ON_TRACK: ON_TRACK,
10863
10930
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10864
10931
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10865
10932
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10874,13 +10941,13 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10874
10941
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10875
10942
  ON_CALL_ERROR: ON_CALL_ERROR,
10876
10943
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10877
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10944
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10878
10945
  ON_CHAT: ON_CHAT,
10879
10946
  ON_SIGNAL: ON_SIGNAL,
10880
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10947
+ ON_DISCONNECTED: ON_DISCONNECTED,
10881
10948
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10882
10949
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10883
- events: events$1,
10950
+ events: events,
10884
10951
  'default': WebRTCPhone
10885
10952
  });
10886
10953
 
@@ -11051,11 +11118,11 @@ var wazoWebsocket = {
11051
11118
  resolve();
11052
11119
  };
11053
11120
 
11054
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
11121
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
11055
11122
  handleError(`Connection error : ${error}`);
11056
11123
  });
11057
11124
 
11058
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
11125
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
11059
11126
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
11060
11127
  client.setOnHeartbeatTimeout(() => {
11061
11128
  handleError('No response to heartbeat');
@@ -11156,7 +11223,7 @@ var webrtc = {
11156
11223
  }),
11157
11224
  };
11158
11225
 
11159
- const parseCandidate$1 = line => {
11226
+ const parseCandidate = line => {
11160
11227
  let parts;
11161
11228
  // Parse both variants.
11162
11229
  if (line.indexOf('a=candidate:') === 0) {
@@ -11247,7 +11314,7 @@ var SymmetricNat = {
11247
11314
  }
11248
11315
 
11249
11316
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
11250
- const cand = parseCandidate$1(e.candidate.candidate);
11317
+ const cand = parseCandidate(e.candidate.candidate);
11251
11318
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
11252
11319
  candidates[cand.relatedPort].push(cand.port);
11253
11320
  } else if (!e.candidate) {
@@ -11315,7 +11382,7 @@ var iceIpv4 = {
11315
11382
  const rawCandidate = e.candidate.candidate;
11316
11383
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
11317
11384
  hasSrflxOrRelay = true;
11318
- const candidate = parseCandidate$1(e.candidate.candidate);
11385
+ const candidate = parseCandidate(e.candidate.candidate);
11319
11386
  ips.push(candidate.ip);
11320
11387
  }
11321
11388
  } else if (!e.candidate) {
@@ -11485,7 +11552,7 @@ const getCallableNumber = (number , country ) => {
11485
11552
  class InvalidSubscription extends Error {}
11486
11553
  class InvalidAuthorization extends Error {}
11487
11554
 
11488
- const logger$7 = IssueReporter$1.loggerFor('simple-auth');
11555
+ const logger$5 = IssueReporter$1.loggerFor('simple-auth');
11489
11556
 
11490
11557
  class Auth {
11491
11558
 
@@ -11520,7 +11587,7 @@ class Auth {
11520
11587
  setApiClientId(this.clientId);
11521
11588
  setRefreshExpiration(this.expiration);
11522
11589
  setOnRefreshToken((token , session ) => {
11523
- logger$7.info('on refresh token done', { token });
11590
+ logger$5.info('on refresh token done', { token });
11524
11591
  setApiToken(token);
11525
11592
  Wazo.Websocket.updateToken(token);
11526
11593
 
@@ -11565,7 +11632,7 @@ class Auth {
11565
11632
  const rawSession = await getApiClient().auth.authenticate(token);
11566
11633
  return this._onAuthenticated(rawSession);
11567
11634
  } catch (e) {
11568
- logger$7.error('on validate token error', e);
11635
+ logger$5.error('on validate token error', e);
11569
11636
  console.warn(e);
11570
11637
  return false;
11571
11638
  }
@@ -11921,7 +11988,7 @@ class AdHocAPIConference {
11921
11988
 
11922
11989
  //
11923
11990
 
11924
- const logger$8 = IssueReporter$1.loggerFor('simple-phone');
11991
+ const logger$4 = IssueReporter$1.loggerFor('simple-phone');
11925
11992
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
11926
11993
  const protocolLogger = IssueReporter$1.loggerFor('sip');
11927
11994
 
@@ -12028,7 +12095,7 @@ class Phone extends Emitter {
12028
12095
  async disconnect() {
12029
12096
  if (this.phone) {
12030
12097
  if (this.phone.hasAnActiveCall()) {
12031
- logger$8.info('hangup call on disconnect');
12098
+ logger$4.info('hangup call on disconnect');
12032
12099
  // $FlowFixMe
12033
12100
  await this.phone.hangup();
12034
12101
  }
@@ -12051,13 +12118,13 @@ class Phone extends Emitter {
12051
12118
  }
12052
12119
 
12053
12120
  async hangup(callSession ) {
12054
- logger$8.info('hangup via simple phone', { callId: callSession.getId() });
12121
+ logger$4.info('hangup via simple phone', { callId: callSession.getId() });
12055
12122
 
12056
12123
  return this.phone && this.phone.hangup(callSession);
12057
12124
  }
12058
12125
 
12059
12126
  async accept(callSession , cameraEnabled ) {
12060
- logger$8.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
12127
+ logger$4.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
12061
12128
 
12062
12129
  return this.phone && this.phone.accept(callSession, cameraEnabled);
12063
12130
  }
@@ -12096,7 +12163,7 @@ class Phone extends Emitter {
12096
12163
  muteViaAPI(callSession ) {
12097
12164
  if (callSession && callSession.callId) {
12098
12165
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
12099
- logger$8.error('Mute via API, error', e);
12166
+ logger$4.error('Mute via API, error', e);
12100
12167
  });
12101
12168
  }
12102
12169
  }
@@ -12104,7 +12171,7 @@ class Phone extends Emitter {
12104
12171
  unmuteViaAPI(callSession ) {
12105
12172
  if (callSession && callSession.callId) {
12106
12173
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
12107
- logger$8.error('Unmute via API, error', e);
12174
+ logger$4.error('Unmute via API, error', e);
12108
12175
  });
12109
12176
  }
12110
12177
  }
@@ -12212,7 +12279,7 @@ class Phone extends Emitter {
12212
12279
 
12213
12280
  // @Deprecated
12214
12281
  getLocalMediaStream(callSession ) {
12215
- logger$8.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12282
+ logger$4.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
12216
12283
 
12217
12284
  return this.phone && this.phone.getLocalStream(callSession);
12218
12285
  }
@@ -12235,20 +12302,20 @@ class Phone extends Emitter {
12235
12302
 
12236
12303
  // @Deprecated
12237
12304
  getRemoteStreamForCall(callSession ) {
12238
- logger$8.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12305
+ logger$4.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
12239
12306
  return this.getRemoteStream(callSession);
12240
12307
  }
12241
12308
 
12242
12309
  // Returns remote streams directly from the peerConnection
12243
12310
  // @Deprecated
12244
12311
  getRemoteStreamsForCall(callSession ) {
12245
- logger$8.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12312
+ logger$4.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
12246
12313
  return this.getLocalStream(callSession);
12247
12314
  }
12248
12315
 
12249
12316
  // @Deprecated
12250
12317
  getRemoteVideoStreamForCall(callSession ) {
12251
- logger$8.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12318
+ logger$4.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
12252
12319
 
12253
12320
  return this.getRemoteVideoStream(callSession);
12254
12321
  }
@@ -12303,13 +12370,13 @@ class Phone extends Emitter {
12303
12370
 
12304
12371
  checkSfu() {
12305
12372
  if (!this.hasSfu()) {
12306
- throw new Error('Sorry your user is not configured to support video conference');
12373
+ throw new SFUNotAvailableError();
12307
12374
  }
12308
12375
  }
12309
12376
 
12310
12377
  _transferEvents() {
12311
12378
  this.unbind();
12312
- [...events, ...transportEvents].forEach(event => {
12379
+ [...events$1, ...transportEvents].forEach(event => {
12313
12380
  this.client.on(event, (...args) =>
12314
12381
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
12315
12382
  });
@@ -12331,10 +12398,10 @@ var Phone$1 = global.wazoTelephonyInstance;
12331
12398
 
12332
12399
  //
12333
12400
 
12334
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
12335
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
12401
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
12402
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
12336
12403
 
12337
- const logger$9 = IssueReporter$1.loggerFor('simple-ws-client');
12404
+ const logger$3 = IssueReporter$1.loggerFor('simple-ws-client');
12338
12405
 
12339
12406
  class Websocket extends Emitter {
12340
12407
 
@@ -12348,9 +12415,9 @@ class Websocket extends Emitter {
12348
12415
  // $FlowFixMe
12349
12416
  this[key] = OTHER_EVENTS[key];
12350
12417
  });
12351
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
12418
+ Object.keys(SOCKET_EVENTS).forEach(key => {
12352
12419
  // $FlowFixMe
12353
- this[key] = SOCKET_EVENTS$1[key];
12420
+ this[key] = SOCKET_EVENTS[key];
12354
12421
  });
12355
12422
  this.eventLists = WebSocketClient.eventLists;
12356
12423
 
@@ -12358,7 +12425,7 @@ class Websocket extends Emitter {
12358
12425
  }
12359
12426
 
12360
12427
  open(host , session ) {
12361
- logger$9.info('open simple WebSocket', { host, token: session.token });
12428
+ logger$3.info('open simple WebSocket', { host, token: session.token });
12362
12429
  this.ws = new WebSocketClient(
12363
12430
  {
12364
12431
  host,
@@ -12386,7 +12453,7 @@ class Websocket extends Emitter {
12386
12453
  }
12387
12454
 
12388
12455
  updateToken(token ) {
12389
- logger$9.info('update token via simple Websocket', { token, ws: !!this.ws });
12456
+ logger$3.info('update token via simple Websocket', { token, ws: !!this.ws });
12390
12457
 
12391
12458
  if (!this.ws) {
12392
12459
  return;
@@ -12414,7 +12481,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
12414
12481
 
12415
12482
  //
12416
12483
 
12417
- const logger$a = IssueReporter$1.loggerFor('room');
12484
+ const logger$2 = IssueReporter$1.loggerFor('room');
12418
12485
 
12419
12486
  class Participant extends Emitter {
12420
12487
 
@@ -12536,7 +12603,7 @@ class Participant extends Emitter {
12536
12603
  }
12537
12604
 
12538
12605
  onTalking(isTalking ) {
12539
- logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12606
+ logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
12540
12607
  this.isTalking = isTalking;
12541
12608
  // you may notice we're not broadcasting: since all participants are getting this info
12542
12609
  // directly from asterisk, there's no need to do so
@@ -12639,7 +12706,7 @@ class Participant extends Emitter {
12639
12706
  }
12640
12707
 
12641
12708
  updateStatus(status , broadcast = true) {
12642
- logger$a.info('updating participant status', { name: this.name, status });
12709
+ logger$2.info('updating participant status', { name: this.name, status });
12643
12710
 
12644
12711
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
12645
12712
  if (status.audioMuted) {
@@ -12687,7 +12754,7 @@ class Participant extends Emitter {
12687
12754
 
12688
12755
  broadcastStatus(inboundStatus = null) {
12689
12756
  const status = inboundStatus || this.getStatus();
12690
- logger$a.info('broadcasting participant status', { callId: this.callId, status });
12757
+ logger$2.info('broadcasting participant status', { callId: this.callId, status });
12691
12758
 
12692
12759
  this.room.sendSignal({
12693
12760
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -12723,9 +12790,9 @@ class LocalParticipant extends Participant {
12723
12790
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12724
12791
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12725
12792
 
12726
- const logger$b = IssueReporter$1.loggerFor('sdk-room');
12793
+ const logger$1 = IssueReporter$1.loggerFor('sdk-room');
12727
12794
 
12728
- class Room$1 extends Emitter {
12795
+ class Room extends Emitter {
12729
12796
 
12730
12797
 
12731
12798
 
@@ -12783,7 +12850,7 @@ class Room$1 extends Emitter {
12783
12850
  extra = {},
12784
12851
  ) {
12785
12852
  super();
12786
- logger$b.info('room initialized', { callId, extension, sourceId, meetingUuid });
12853
+ logger$1.info('room initialized', { callId, extension, sourceId, meetingUuid });
12787
12854
 
12788
12855
  // Represents the room callSession
12789
12856
  this.callSession = callSession;
@@ -12849,7 +12916,7 @@ class Room$1 extends Emitter {
12849
12916
  * @returns {Promise<Room>}
12850
12917
  */
12851
12918
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
12852
- logger$b.info('connecting to room', { extension, audioOnly, room: !!room });
12919
+ logger$1.info('connecting to room', { extension, audioOnly, room: !!room });
12853
12920
 
12854
12921
  if (!room) {
12855
12922
  await Wazo.Phone.connect();
@@ -12862,7 +12929,7 @@ class Room$1 extends Emitter {
12862
12929
 
12863
12930
  // Call_created is triggered before call_accepted, so we have to listen for it here.
12864
12931
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
12865
- logger$b.info('room call received via WS', { callId: data.call_id });
12932
+ logger$1.info('room call received via WS', { callId: data.call_id });
12866
12933
  if (room) {
12867
12934
  room.setCallId(data.call_id);
12868
12935
  }
@@ -12870,7 +12937,7 @@ class Room$1 extends Emitter {
12870
12937
 
12871
12938
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
12872
12939
  // eslint-disable-next-line no-param-reassign
12873
- room = new Room$1(callSession, extension, null, null, extra);
12940
+ room = new Room(callSession, extension, null, null, extra);
12874
12941
 
12875
12942
  // Wait for the call to be accepted
12876
12943
  await new Promise((resolve, reject) => {
@@ -12891,7 +12958,7 @@ class Room$1 extends Emitter {
12891
12958
  // Retrieve conference
12892
12959
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
12893
12960
 
12894
- logger$b.info('connected to room', {
12961
+ logger$1.info('connected to room', {
12895
12962
  sourceId: conference ? conference.sourceId : null,
12896
12963
  name: conference ? conference.name : null,
12897
12964
  });
@@ -12901,7 +12968,7 @@ class Room$1 extends Emitter {
12901
12968
  room.setName(conference.name);
12902
12969
  }
12903
12970
  } else if (meeting) {
12904
- logger$b.info('Already connected to meeting', {
12971
+ logger$1.info('Already connected to meeting', {
12905
12972
  uuid: meeting.uuid,
12906
12973
  name: meeting.name,
12907
12974
  });
@@ -12914,13 +12981,13 @@ class Room$1 extends Emitter {
12914
12981
  }
12915
12982
 
12916
12983
  static disconnect() {
12917
- logger$b.info('static disconnection to room');
12984
+ logger$1.info('static disconnection to room');
12918
12985
 
12919
12986
  Wazo.Phone.disconnect();
12920
12987
  }
12921
12988
 
12922
12989
  async disconnect() {
12923
- logger$b.info('disconnection to room called');
12990
+ logger$1.info('disconnection to room called');
12924
12991
 
12925
12992
  await Wazo.Phone.hangup(this.callSession);
12926
12993
  this.callSession = null;
@@ -12940,19 +13007,19 @@ class Room$1 extends Emitter {
12940
13007
  }
12941
13008
 
12942
13009
  setSourceId(sourceId ) {
12943
- logger$b.info('set room source id', { sourceId });
13010
+ logger$1.info('set room source id', { sourceId });
12944
13011
 
12945
13012
  this.sourceId = sourceId;
12946
13013
  }
12947
13014
 
12948
13015
  setMeetingUuid(meetingUuid ) {
12949
- logger$b.info('set meeting uuid', { meetingUuid });
13016
+ logger$1.info('set meeting uuid', { meetingUuid });
12950
13017
 
12951
13018
  this.meetingUuid = meetingUuid;
12952
13019
  }
12953
13020
 
12954
13021
  setCallId(callId ) {
12955
- logger$b.info('set room call id', { callId });
13022
+ logger$1.info('set room call id', { callId });
12956
13023
 
12957
13024
  if (callId) {
12958
13025
  this.callId = callId;
@@ -12960,7 +13027,7 @@ class Room$1 extends Emitter {
12960
13027
  }
12961
13028
 
12962
13029
  setName(name ) {
12963
- logger$b.info('set room name', { name });
13030
+ logger$1.info('set room name', { name });
12964
13031
 
12965
13032
  this.name = name;
12966
13033
  }
@@ -12979,7 +13046,7 @@ class Room$1 extends Emitter {
12979
13046
  }
12980
13047
 
12981
13048
  async startScreenSharing(constraints ) {
12982
- logger$b.info('start room screen sharing', { constraints });
13049
+ logger$1.info('start room screen sharing', { constraints });
12983
13050
 
12984
13051
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
12985
13052
  if (!screensharingStream) {
@@ -12993,7 +13060,7 @@ class Room$1 extends Emitter {
12993
13060
  }
12994
13061
 
12995
13062
  async stopScreenSharing(restoreLocalStream = true) {
12996
- logger$b.info('stop room screen sharing');
13063
+ logger$1.info('stop room screen sharing');
12997
13064
 
12998
13065
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
12999
13066
 
@@ -13005,7 +13072,7 @@ class Room$1 extends Emitter {
13005
13072
  }
13006
13073
 
13007
13074
  turnCameraOff() {
13008
- logger$b.info('turn room camera off');
13075
+ logger$1.info('turn room camera off');
13009
13076
 
13010
13077
  Wazo.Phone.turnCameraOff(this.callSession);
13011
13078
 
@@ -13015,7 +13082,7 @@ class Room$1 extends Emitter {
13015
13082
  }
13016
13083
 
13017
13084
  turnCameraOn() {
13018
- logger$b.info('turn room camera on');
13085
+ logger$1.info('turn room camera on');
13019
13086
 
13020
13087
  Wazo.Phone.turnCameraOn(this.callSession);
13021
13088
 
@@ -13025,7 +13092,7 @@ class Room$1 extends Emitter {
13025
13092
  }
13026
13093
 
13027
13094
  mute() {
13028
- logger$b.info('mute room');
13095
+ logger$1.info('mute room');
13029
13096
 
13030
13097
  Wazo.Phone.mute(this.callSession);
13031
13098
 
@@ -13033,7 +13100,7 @@ class Room$1 extends Emitter {
13033
13100
  }
13034
13101
 
13035
13102
  unmute() {
13036
- logger$b.info('unmute room');
13103
+ logger$1.info('unmute room');
13037
13104
 
13038
13105
  Wazo.Phone.unmute(this.callSession);
13039
13106
 
@@ -13053,7 +13120,7 @@ class Room$1 extends Emitter {
13053
13120
  }
13054
13121
 
13055
13122
  hold() {
13056
- logger$b.info('hold room');
13123
+ logger$1.info('hold room');
13057
13124
 
13058
13125
  Wazo.Phone.hold(this.callSession, true);
13059
13126
 
@@ -13063,7 +13130,7 @@ class Room$1 extends Emitter {
13063
13130
  }
13064
13131
 
13065
13132
  async resume() {
13066
- logger$b.info('resume room');
13133
+ logger$1.info('resume room');
13067
13134
 
13068
13135
  const newStream = await Wazo.Phone.resume(this.callSession, true);
13069
13136
 
@@ -13091,13 +13158,13 @@ class Room$1 extends Emitter {
13091
13158
  }
13092
13159
 
13093
13160
  sendDTMF(tone ) {
13094
- logger$b.info('send room DTMF', { tone });
13161
+ logger$1.info('send room DTMF', { tone });
13095
13162
 
13096
13163
  Wazo.Phone.sendDTMF(tone, this.callSession);
13097
13164
  }
13098
13165
 
13099
13166
  async sendReinvite(newConstraints = null) {
13100
- logger$b.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13167
+ logger$1.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13101
13168
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
13102
13169
 
13103
13170
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13156,7 +13223,7 @@ class Room$1 extends Emitter {
13156
13223
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13157
13224
 
13158
13225
  this.on(this.ON_AUDIO_STREAM, stream => {
13159
- logger$b.info('on room audio stream');
13226
+ logger$1.info('on room audio stream');
13160
13227
 
13161
13228
  this.audioStream = stream;
13162
13229
  if (!this.roomAudioElement) {
@@ -13169,7 +13236,7 @@ class Room$1 extends Emitter {
13169
13236
  });
13170
13237
 
13171
13238
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13172
- logger$b.info('on room video stream', { streamId });
13239
+ logger$1.info('on room video stream', { streamId });
13173
13240
 
13174
13241
  this._mapMsid(sipSession.body.body);
13175
13242
 
@@ -13184,7 +13251,7 @@ class Room$1 extends Emitter {
13184
13251
  });
13185
13252
 
13186
13253
  this.on(this.ON_REMOVE_STREAM, stream => {
13187
- logger$b.info('on room remove stream');
13254
+ logger$1.info('on room remove stream');
13188
13255
 
13189
13256
  const participant = this.participants.find(someParticipant =>
13190
13257
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13316,7 +13383,7 @@ class Room$1 extends Emitter {
13316
13383
  const requester = this._getParticipantFromCallId(origin.callId);
13317
13384
  if (requester) {
13318
13385
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13319
- logger$b.info('trigger room requester status', { origin });
13386
+ logger$1.info('trigger room requester status', { origin });
13320
13387
  requester.triggerUpdate('REQUESTER_UPDATE');
13321
13388
  }
13322
13389
  break;
@@ -13347,24 +13414,24 @@ class Room$1 extends Emitter {
13347
13414
 
13348
13415
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13349
13416
  if (participant.user_uuid === session.uuid) {
13350
- logger$b.info('room current user joined');
13417
+ logger$1.info('room current user joined');
13351
13418
 
13352
13419
  // Retrieve participants via an API calls
13353
13420
  const conferenceId = this.sourceId || payload.data.conference_id;
13354
13421
  let response;
13355
13422
  try {
13356
13423
  if (this.meetingUuid) {
13357
- logger$b.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13424
+ logger$1.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13358
13425
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13359
13426
  } else {
13360
- logger$b.info('fetching conference participants', { conferenceId });
13427
+ logger$1.info('fetching conference participants', { conferenceId });
13361
13428
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13362
13429
  }
13363
13430
  } catch (e) {
13364
- logger$b.error('room participants fetching, error', e);
13431
+ logger$1.error('room participants fetching, error', e);
13365
13432
  }
13366
13433
  if (response) {
13367
- logger$b.info('conference participants fetched', { nb: response.items.length });
13434
+ logger$1.info('conference participants fetched', { nb: response.items.length });
13368
13435
  participants = response.items.map(item => {
13369
13436
  const isMe = item.call_id === this.callId;
13370
13437
 
@@ -13391,7 +13458,7 @@ class Room$1 extends Emitter {
13391
13458
  ? new Wazo.RemoteParticipant(this, participant)
13392
13459
  : null;
13393
13460
 
13394
- logger$b.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13461
+ logger$1.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13395
13462
 
13396
13463
  if (remoteParticipant) {
13397
13464
  this.participants.push(remoteParticipant);
@@ -13556,12 +13623,12 @@ class Room$1 extends Emitter {
13556
13623
 
13557
13624
  //
13558
13625
 
13559
- const logger$c = IssueReporter$1.loggerFor('sdk-sip-room');
13626
+ const logger = IssueReporter$1.loggerFor('sdk-sip-room');
13560
13627
 
13561
- class SipRoom extends Room$1 {
13628
+ class SipRoom extends Room {
13562
13629
 
13563
13630
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
13564
- logger$c.info('connecting to sip room', { extension, audioOnly, room: !!room });
13631
+ logger.info('connecting to sip room', { extension, audioOnly, room: !!room });
13565
13632
 
13566
13633
  if (!room) {
13567
13634
  await Wazo.Phone.connect();
@@ -13577,7 +13644,7 @@ class SipRoom extends Room$1 {
13577
13644
  room.setCallId(room.callSession.call.id);
13578
13645
  }
13579
13646
 
13580
- logger$c.info('connected to room', {
13647
+ logger.info('connected to room', {
13581
13648
  extension: room.extension,
13582
13649
  });
13583
13650
 
@@ -13585,7 +13652,7 @@ class SipRoom extends Room$1 {
13585
13652
  }
13586
13653
 
13587
13654
  mute() {
13588
- logger$c.info('mute sip room');
13655
+ logger.info('mute sip room');
13589
13656
 
13590
13657
  Wazo.Phone.mute(this.callSession, false);
13591
13658
 
@@ -13593,7 +13660,7 @@ class SipRoom extends Room$1 {
13593
13660
  }
13594
13661
 
13595
13662
  unmute() {
13596
- logger$c.info('unmute sip room');
13663
+ logger.info('unmute sip room');
13597
13664
 
13598
13665
  Wazo.Phone.unmute(this.callSession, false);
13599
13666
 
@@ -13806,7 +13873,7 @@ const Wazo = {
13806
13873
  Auth: Auth$1,
13807
13874
  Phone: Phone$1,
13808
13875
  Websocket: Websocket$1,
13809
- Room: Room$1,
13876
+ Room,
13810
13877
  SipRoom,
13811
13878
  RemoteParticipant,
13812
13879
  LocalParticipant,
@@ -13839,7 +13906,7 @@ const Wazo = {
13839
13906
  Session,
13840
13907
  Voicemail,
13841
13908
  Relocation,
13842
- ConferenceRoom: Room,
13909
+ ConferenceRoom: Room$1,
13843
13910
  CallSession,
13844
13911
  IndirectTransfer,
13845
13912
  SwitchboardCall,
@@ -13864,6 +13931,7 @@ const Wazo = {
13864
13931
  InvalidSubscription,
13865
13932
  InvalidAuthorization,
13866
13933
  CanceledCallError,
13934
+ SFUNotAvailableError,
13867
13935
  };
13868
13936
 
13869
13937
  if (window) {
@@ -13906,6 +13974,7 @@ var index = {
13906
13974
  WazoWebSocketClient: WebSocketClient,
13907
13975
  BadResponse,
13908
13976
  ServerError,
13977
+ SFUNotAvailableError,
13909
13978
  Call,
13910
13979
  CallSession,
13911
13980
  CTIPhone,
@@ -13925,13 +13994,13 @@ var index = {
13925
13994
  Session,
13926
13995
  Voicemail,
13927
13996
  Relocation,
13928
- Room,
13997
+ Room: Room$1,
13929
13998
  IssueReporter: IssueReporter$1,
13930
13999
  DebugDevice,
13931
14000
  PROFILE_STATE: STATE,
13932
14001
  FORWARD_KEYS,
13933
14002
  LINE_STATE,
13934
- SOCKET_EVENTS,
14003
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
13935
14004
  Wazo,
13936
14005
  WebRTCPhone,
13937
14006
  Meeting,