@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
@@ -469,11 +469,11 @@ var IssueReporter$1 = new IssueReporter();
469
469
 
470
470
  const methods = ['head', 'get', 'post', 'put', 'delete'];
471
471
 
472
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
472
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
473
473
 
474
474
  // Use a function here to be able to mock it in tests
475
475
  const realFetch = () => {
476
- if (typeof document !== 'undefined') {
476
+ if (typeof document !== 'undefined' && window.fetch) {
477
477
  // Browser
478
478
  return window.fetch;
479
479
  }
@@ -608,7 +608,7 @@ class ApiRequester {
608
608
  };
609
609
 
610
610
  if (this.refreshTokenPromise) {
611
- logger.info('A token is already refreshing, waiting ...', { url });
611
+ logger$c.info('A token is already refreshing, waiting ...', { url });
612
612
  await this.refreshTokenPromise;
613
613
  }
614
614
 
@@ -628,7 +628,7 @@ class ApiRequester {
628
628
  return promise.then(async (err ) => {
629
629
  // Check if the token is still valid
630
630
  if (firstCall && this._checkTokenExpired(response, err)) {
631
- logger.warn('token expired', { error: err.reason });
631
+ logger$c.warn('token expired', { error: err.reason });
632
632
  // Replay the call after refreshing the token
633
633
  return this._replayWithNewToken(err, path, method, body, headers, parse);
634
634
  }
@@ -638,7 +638,7 @@ class ApiRequester {
638
638
  : exceptionClass.fromResponse(err, response.status);
639
639
 
640
640
  if (this.shouldLogErrors) {
641
- logger.error('API error', error);
641
+ logger$c.error('API error', error);
642
642
  }
643
643
 
644
644
  throw error;
@@ -648,7 +648,7 @@ class ApiRequester {
648
648
  return newParse(response, isJson);
649
649
  }).catch(error => {
650
650
  if (this.shouldLogErrors) {
651
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
651
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
652
652
  }
653
653
 
654
654
  throw error;
@@ -676,13 +676,13 @@ class ApiRequester {
676
676
  ) {
677
677
  const isTokenNotFound = this._isTokenNotFound(err);
678
678
  let newPath = path;
679
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
679
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
680
680
 
681
681
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
682
682
 
683
683
  return this.refreshTokenPromise.then(() => {
684
684
  this.refreshTokenPromise = null;
685
- logger.info('token refreshed', { isTokenNotFound });
685
+ logger$c.info('token refreshed', { isTokenNotFound });
686
686
  if (isTokenNotFound) {
687
687
  const pathParts = path.split('/');
688
688
  pathParts.pop();
@@ -1933,7 +1933,7 @@ class Contact {
1933
1933
  this[key] = old[key] || this[key];
1934
1934
  });
1935
1935
 
1936
- if (old.lineState && !this.lineState) {
1936
+ if (old.lineState) {
1937
1937
  this.lineState = old.lineState;
1938
1938
  }
1939
1939
 
@@ -3263,8 +3263,10 @@ var updateFrom = (instance , from ) => {
3263
3263
 
3264
3264
 
3265
3265
 
3266
+
3266
3267
 
3267
3268
 
3269
+
3268
3270
 
3269
3271
 
3270
3272
 
@@ -3281,6 +3283,7 @@ var updateFrom = (instance , from ) => {
3281
3283
 
3282
3284
 
3283
3285
 
3286
+
3284
3287
 
3285
3288
 
3286
3289
  class CallSession {
@@ -3300,8 +3303,12 @@ class CallSession {
3300
3303
 
3301
3304
 
3302
3305
 
3306
+
3307
+
3303
3308
 
3304
3309
 
3310
+
3311
+
3305
3312
 
3306
3313
 
3307
3314
 
@@ -3339,6 +3346,8 @@ class CallSession {
3339
3346
 
3340
3347
 
3341
3348
 
3349
+
3350
+
3342
3351
 
3343
3352
  constructor({
3344
3353
  answered,
@@ -3352,6 +3361,8 @@ class CallSession {
3352
3361
  paused,
3353
3362
  ringing,
3354
3363
  startTime,
3364
+ creationTime,
3365
+ endTime,
3355
3366
  cameraEnabled,
3356
3367
  dialedExtension,
3357
3368
  sipCallId,
@@ -3364,12 +3375,15 @@ class CallSession {
3364
3375
  recording,
3365
3376
  recordingPaused,
3366
3377
  videoRemotelyDowngraded,
3378
+ sipSession,
3367
3379
  } ) {
3368
3380
  this.callId = callId;
3369
3381
  this.sipCallId = sipCallId;
3370
3382
  this.displayName = displayName;
3371
3383
  this.number = number;
3384
+ this.creationTime = creationTime;
3372
3385
  this.startTime = startTime;
3386
+ this.endTime = endTime;
3373
3387
  this.isCaller = isCaller;
3374
3388
  this.answered = answered;
3375
3389
  this.answeredBySystem = answeredBySystem;
@@ -3388,6 +3402,7 @@ class CallSession {
3388
3402
  this.recording = recording || false;
3389
3403
  this.recordingPaused = recordingPaused || false;
3390
3404
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3405
+ this.sipSession = sipSession;
3391
3406
 
3392
3407
  // Useful to compare instead of instanceof with minified code
3393
3408
  this.type = 'CallSession';
@@ -4063,7 +4078,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4063
4078
 
4064
4079
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4065
4080
 
4066
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4081
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4067
4082
 
4068
4083
  class CTIPhone extends Emitter {
4069
4084
 
@@ -4076,7 +4091,7 @@ class CTIPhone extends Emitter {
4076
4091
 
4077
4092
  constructor(session , isMobile = false, callbackAllLines = false) {
4078
4093
  super();
4079
- logger$1.info('CTI Phone created');
4094
+ logger$b.info('CTI Phone created');
4080
4095
  this.session = session;
4081
4096
  this.isMobile = isMobile;
4082
4097
  this.callbackAllLines = callbackAllLines;
@@ -4137,7 +4152,7 @@ class CTIPhone extends Emitter {
4137
4152
  }
4138
4153
 
4139
4154
  async makeCall(number , line ) {
4140
- logger$1.info('make CTI call', { number });
4155
+ logger$b.info('make CTI call', { number });
4141
4156
 
4142
4157
  if (!number) {
4143
4158
  return null;
@@ -4160,7 +4175,7 @@ class CTIPhone extends Emitter {
4160
4175
  if (!callSession) {
4161
4176
  return Promise.resolve(null);
4162
4177
  }
4163
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4178
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4164
4179
 
4165
4180
  if (!this.currentCall) {
4166
4181
  this.currentCall = callSession.call;
@@ -4173,7 +4188,7 @@ class CTIPhone extends Emitter {
4173
4188
  if (!callSession) {
4174
4189
  return;
4175
4190
  }
4176
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4191
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4177
4192
 
4178
4193
  this.currentCall = undefined;
4179
4194
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4183,7 +4198,7 @@ class CTIPhone extends Emitter {
4183
4198
  if (!callSession) {
4184
4199
  return Promise.resolve(false);
4185
4200
  }
4186
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4201
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4187
4202
 
4188
4203
  try {
4189
4204
  await CallApi.cancelCall(callSession);
@@ -4194,7 +4209,7 @@ class CTIPhone extends Emitter {
4194
4209
  this.eventEmitter.emit('onCallEnded', callSession);
4195
4210
  return true;
4196
4211
  } catch (e) {
4197
- logger$1.error('hangup CTI call, error', e);
4212
+ logger$b.error('hangup CTI call, error', e);
4198
4213
 
4199
4214
  this.eventEmitter.emit('onCallFailed', callSession);
4200
4215
  return false;
@@ -4207,7 +4222,7 @@ class CTIPhone extends Emitter {
4207
4222
  if (!callSession) {
4208
4223
  return;
4209
4224
  }
4210
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4225
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4211
4226
 
4212
4227
  await CallApi.cancelCall(callSession);
4213
4228
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4217,7 +4232,7 @@ class CTIPhone extends Emitter {
4217
4232
  if (!callSession) {
4218
4233
  return;
4219
4234
  }
4220
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4235
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4221
4236
 
4222
4237
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4223
4238
  }
@@ -4230,19 +4245,19 @@ class CTIPhone extends Emitter {
4230
4245
  if (!callSession) {
4231
4246
  return;
4232
4247
  }
4233
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4248
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4234
4249
 
4235
4250
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4236
4251
  }
4237
4252
 
4238
4253
  async cancelCTIIndirectTransfer(transferId ) {
4239
- logger$1.info('cancel CTI transfer', { transferId });
4254
+ logger$b.info('cancel CTI transfer', { transferId });
4240
4255
 
4241
4256
  return CallApi.cancelCallTransfer(transferId);
4242
4257
  }
4243
4258
 
4244
4259
  async confirmCTIIndirectTransfer(transferId ) {
4245
- logger$1.info('confirm CTI transfer', { transferId });
4260
+ logger$b.info('confirm CTI transfer', { transferId });
4246
4261
 
4247
4262
  return CallApi.confirmCallTransfer(transferId);
4248
4263
  }
@@ -4251,19 +4266,19 @@ class CTIPhone extends Emitter {
4251
4266
  if (!callSession) {
4252
4267
  return;
4253
4268
  }
4254
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4269
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4255
4270
 
4256
4271
  return CallApi.sendDTMF(callSession.callId, digits);
4257
4272
  }
4258
4273
 
4259
4274
  onConnectionMade() {
4260
- logger$1.info('on CTI connection made');
4275
+ logger$b.info('on CTI connection made');
4261
4276
 
4262
4277
  this.eventEmitter.emit('onCallAccepted');
4263
4278
  }
4264
4279
 
4265
4280
  async close() {
4266
- logger$1.info('CTI close');
4281
+ logger$b.info('CTI close');
4267
4282
 
4268
4283
  return Promise.resolve();
4269
4284
  }
@@ -4272,7 +4287,7 @@ class CTIPhone extends Emitter {
4272
4287
  if (!callSession) {
4273
4288
  return;
4274
4289
  }
4275
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4290
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4276
4291
 
4277
4292
  return CallApi.hold(callSession.callId);
4278
4293
  }
@@ -4281,7 +4296,7 @@ class CTIPhone extends Emitter {
4281
4296
  if (!callSession) {
4282
4297
  return;
4283
4298
  }
4284
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4299
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4285
4300
 
4286
4301
  return CallApi.resume(callSession.callId);
4287
4302
  }
@@ -4290,7 +4305,7 @@ class CTIPhone extends Emitter {
4290
4305
  if (!callSession) {
4291
4306
  return;
4292
4307
  }
4293
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4308
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4294
4309
 
4295
4310
  return CallApi.mute(callSession.callId);
4296
4311
  }
@@ -4299,7 +4314,7 @@ class CTIPhone extends Emitter {
4299
4314
  if (!callSession) {
4300
4315
  return;
4301
4316
  }
4302
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4317
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4303
4318
 
4304
4319
  return CallApi.unmute(callSession.callId);
4305
4320
  }
@@ -5308,7 +5323,7 @@ const AGENTD_VERSION = '1.0';
5308
5323
  const WEBHOOKD_VERSION = '1.0';
5309
5324
  const AMID_VERSION = '1.0';
5310
5325
 
5311
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5326
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5312
5327
 
5313
5328
  class ApiClient {
5314
5329
 
@@ -5360,12 +5375,12 @@ class ApiClient {
5360
5375
  }
5361
5376
 
5362
5377
  async forceRefreshToken() {
5363
- logger$2.info('forcing refresh token, calling callback');
5378
+ logger$a.info('forcing refresh token, calling callback');
5364
5379
  return this.refreshTokenCallback();
5365
5380
  }
5366
5381
 
5367
5382
  async refreshTokenCallback() {
5368
- logger$2.info('refresh token callback called', {
5383
+ logger$a.info('refresh token callback called', {
5369
5384
  refreshToken: this.refreshToken,
5370
5385
  refreshBackend: this.refreshBackend,
5371
5386
  refreshExpiration: this.refreshExpiration,
@@ -5383,7 +5398,7 @@ class ApiClient {
5383
5398
  this.isMobile,
5384
5399
  );
5385
5400
 
5386
- logger$2.info('token refreshed', { token: session.token });
5401
+ logger$a.info('token refreshed', { token: session.token });
5387
5402
 
5388
5403
  if (this.onRefreshToken) {
5389
5404
  this.onRefreshToken(session.token, session);
@@ -5524,7 +5539,7 @@ var getApiClient = (forServer ) => {
5524
5539
  class InvalidSubscription extends Error {}
5525
5540
  class InvalidAuthorization extends Error {}
5526
5541
 
5527
- const logger$3 = IssueReporter$1.loggerFor('simple-auth');
5542
+ const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5528
5543
 
5529
5544
  class Auth {
5530
5545
 
@@ -5559,7 +5574,7 @@ class Auth {
5559
5574
  setApiClientId(this.clientId);
5560
5575
  setRefreshExpiration(this.expiration);
5561
5576
  setOnRefreshToken((token , session ) => {
5562
- logger$3.info('on refresh token done', { token });
5577
+ logger$9.info('on refresh token done', { token });
5563
5578
  setApiToken(token);
5564
5579
  Wazo.Websocket.updateToken(token);
5565
5580
 
@@ -5604,7 +5619,7 @@ class Auth {
5604
5619
  const rawSession = await getApiClient().auth.authenticate(token);
5605
5620
  return this._onAuthenticated(rawSession);
5606
5621
  } catch (e) {
5607
- logger$3.error('on validate token error', e);
5622
+ logger$9.error('on validate token error', e);
5608
5623
  console.warn(e);
5609
5624
  return false;
5610
5625
  }
@@ -5960,7 +5975,7 @@ class AdHocAPIConference {
5960
5975
 
5961
5976
  /* */
5962
5977
 
5963
- const parseCandidate = (candidate ) => {
5978
+ const parseCandidate$1 = (candidate ) => {
5964
5979
  if (!candidate) {
5965
5980
  return null;
5966
5981
  }
@@ -6072,11 +6087,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6072
6087
 
6073
6088
  // $FlowFixMe
6074
6089
  setRemoteSessionDescription(sessionDescription ) {
6075
- const result = super.setRemoteSessionDescription(sessionDescription);
6090
+ try {
6091
+ const result = super.setRemoteSessionDescription(sessionDescription);
6076
6092
 
6077
- this.eventEmitter.emit('setDescription', sessionDescription);
6093
+ this.eventEmitter.emit('setDescription', sessionDescription);
6078
6094
 
6079
- return result;
6095
+ return result;
6096
+ } catch (error) {
6097
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
6098
+ throw error;
6099
+ }
6080
6100
  }
6081
6101
 
6082
6102
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6114,7 +6134,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6114
6134
  this.peerConnectionDelegate.onicecandidate = event => {
6115
6135
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6116
6136
  if (event.candidate) {
6117
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
6137
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6118
6138
  }
6119
6139
  };
6120
6140
 
@@ -6578,7 +6598,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6578
6598
  const SEND_STATS_DELAY = 5000;
6579
6599
 
6580
6600
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6581
- const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6601
+ const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6582
6602
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6583
6603
 
6584
6604
  // events
@@ -6592,14 +6612,14 @@ const TRANSPORT_ERROR = 'transportError';
6592
6612
  const MESSAGE = 'message';
6593
6613
  const ACCEPTED = 'accepted';
6594
6614
  const REJECTED = 'rejected';
6595
- const ON_TRACK = 'onTrack';
6596
- const ON_REINVITE = 'reinvite';
6615
+ const ON_TRACK$1 = 'onTrack';
6616
+ const ON_REINVITE$1 = 'reinvite';
6597
6617
  const ON_ERROR = 'onError';
6598
6618
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6599
- const ON_NETWORK_STATS = 'onNetworkStats';
6600
- const ON_DISCONNECTED = 'onDisconnected';
6619
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6620
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6601
6621
 
6602
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6622
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6603
6623
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6604
6624
  class CanceledCallError extends Error {}
6605
6625
 
@@ -6735,12 +6755,12 @@ class WebRTCClient extends Emitter {
6735
6755
  this.MESSAGE = MESSAGE;
6736
6756
  this.ACCEPTED = ACCEPTED;
6737
6757
  this.REJECTED = REJECTED;
6738
- this.ON_TRACK = ON_TRACK;
6739
- this.ON_REINVITE = ON_REINVITE;
6758
+ this.ON_TRACK = ON_TRACK$1;
6759
+ this.ON_REINVITE = ON_REINVITE$1;
6740
6760
  this.ON_ERROR = ON_ERROR;
6741
6761
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6742
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6743
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6762
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6763
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6744
6764
  }
6745
6765
 
6746
6766
  configureMedia(media ) {
@@ -6757,13 +6777,13 @@ class WebRTCClient extends Emitter {
6757
6777
 
6758
6778
  createUserAgent(configOverrides ) {
6759
6779
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6760
- logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
6780
+ logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6761
6781
 
6762
6782
  webRTCConfiguration.delegate = {
6763
6783
  onConnect: this.onConnect.bind(this),
6764
6784
  onDisconnect: this.onDisconnect.bind(this),
6765
6785
  onInvite: (invitation ) => {
6766
- logger$4.info('sdk webrtc on invite', {
6786
+ logger$8.info('sdk webrtc on invite', {
6767
6787
  method: 'delegate.onInvite',
6768
6788
  id: invitation.id,
6769
6789
  remoteURI: invitation.remoteURI,
@@ -6806,7 +6826,7 @@ class WebRTCClient extends Emitter {
6806
6826
  }
6807
6827
 
6808
6828
  onConnect() {
6809
- logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6829
+ logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6810
6830
  this.eventEmitter.emit(CONNECTED);
6811
6831
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6812
6832
  this.registerer.waitingToggle(false);
@@ -6815,7 +6835,7 @@ class WebRTCClient extends Emitter {
6815
6835
  }
6816
6836
 
6817
6837
  async onDisconnect(error ) {
6818
- logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6838
+ logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6819
6839
  this.connectionPromise = null;
6820
6840
  // The UA will attempt to reconnect automatically when an error occurred
6821
6841
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6840,37 +6860,37 @@ class WebRTCClient extends Emitter {
6840
6860
  };
6841
6861
 
6842
6862
  if (this.skipRegister) {
6843
- logger$4.info('sdk webrtc skip register...', logInfo);
6863
+ logger$8.info('sdk webrtc skip register...', logInfo);
6844
6864
  return Promise.resolve();
6845
6865
  }
6846
6866
 
6847
- logger$4.info('sdk webrtc registering...', logInfo);
6867
+ logger$8.info('sdk webrtc registering...', logInfo);
6848
6868
 
6849
6869
  if (!this.userAgent) {
6850
- logger$4.info('sdk webrtc recreating User Agent');
6870
+ logger$8.info('sdk webrtc recreating User Agent');
6851
6871
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6852
6872
  }
6853
6873
  if (!this.userAgent || this.isRegistered()) {
6854
- logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
6874
+ logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6855
6875
  return Promise.resolve();
6856
6876
  }
6857
6877
 
6858
6878
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6859
- logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
6879
+ logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6860
6880
  return Promise.resolve();
6861
6881
  }
6862
6882
 
6863
6883
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6864
6884
 
6865
6885
  const onRegisterFailed = () => {
6866
- logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6886
+ logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6867
6887
  this.connectionPromise = null;
6868
6888
  if (this.registerer && this.registerer.waiting) {
6869
6889
  this.registerer.waitingToggle(false);
6870
6890
  }
6871
6891
 
6872
6892
  if (tries <= MAX_REGISTER_TRIES) {
6873
- logger$4.info('sdk webrtc registering, retrying...', { tries });
6893
+ logger$8.info('sdk webrtc registering, retrying...', { tries });
6874
6894
  setTimeout(() => this.register(tries + 1), 300);
6875
6895
  }
6876
6896
  };
@@ -6879,18 +6899,18 @@ class WebRTCClient extends Emitter {
6879
6899
  // Avoid race condition with the close method called just before register and setting userAgent to null
6880
6900
  // during the resolution of the primise.
6881
6901
  if (!this.userAgent) {
6882
- logger$4.info('sdk webrtc recreating User Agent after connection');
6902
+ logger$8.info('sdk webrtc recreating User Agent after connection');
6883
6903
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6884
6904
  }
6885
6905
 
6886
- logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6906
+ logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6887
6907
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6888
6908
  this.connectionPromise = null;
6889
6909
  this._monkeyPatchRegisterer(this.registerer);
6890
6910
 
6891
6911
  // Bind registerer events
6892
6912
  this.registerer.stateChange.addListener(newState => {
6893
- logger$4.info('sdk webrtc registering, state changed', { newState });
6913
+ logger$8.info('sdk webrtc registering, state changed', { newState });
6894
6914
 
6895
6915
  if (newState === registererState.RegistererState.Registered && this.registerer
6896
6916
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6903,7 +6923,7 @@ class WebRTCClient extends Emitter {
6903
6923
  const options = {
6904
6924
  requestDelegate: {
6905
6925
  onReject: response => {
6906
- logger$4.error('sdk webrtc registering, rejected', { response });
6926
+ logger$8.error('sdk webrtc registering, rejected', { response });
6907
6927
 
6908
6928
  onRegisterFailed();
6909
6929
  },
@@ -6911,13 +6931,13 @@ class WebRTCClient extends Emitter {
6911
6931
  };
6912
6932
 
6913
6933
  return this.registerer.register(options).catch((e) => {
6914
- logger$4.error('sdk webrtc registering, error', e);
6934
+ logger$8.error('sdk webrtc registering, error', e);
6915
6935
 
6916
6936
  this.eventEmitter.emit(REGISTRATION_FAILED);
6917
6937
  return e;
6918
6938
  });
6919
6939
  }).catch(error => {
6920
- logger$4.error('sdk webrtc registering, transport error', error);
6940
+ logger$8.error('sdk webrtc registering, transport error', error);
6921
6941
  onRegisterFailed();
6922
6942
  });
6923
6943
  }
@@ -6946,21 +6966,21 @@ class WebRTCClient extends Emitter {
6946
6966
  }
6947
6967
 
6948
6968
  unregister() {
6949
- logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6969
+ logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6950
6970
  if (!this.registerer) {
6951
6971
  return Promise.resolve();
6952
6972
  }
6953
6973
 
6954
6974
  try {
6955
6975
  return this.registerer.unregister().then(() => {
6956
- logger$4.info('sdk webrtc unregistered');
6976
+ logger$8.info('sdk webrtc unregistered');
6957
6977
  this._cleanupRegister();
6958
6978
  }).catch(e => {
6959
- logger$4.error('sdk webrtc unregistering, promise error', e);
6979
+ logger$8.error('sdk webrtc unregistering, promise error', e);
6960
6980
  this._cleanupRegister();
6961
6981
  });
6962
6982
  } catch (e) {
6963
- logger$4.error('sdk webrtc unregistering, error', e);
6983
+ logger$8.error('sdk webrtc unregistering, error', e);
6964
6984
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6965
6985
  // error when the registerer is in a bad state
6966
6986
  this._cleanupRegister();
@@ -6968,7 +6988,7 @@ class WebRTCClient extends Emitter {
6968
6988
  }
6969
6989
 
6970
6990
  stop() {
6971
- logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6991
+ logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6972
6992
  if (!this.userAgent) {
6973
6993
  return Promise.resolve();
6974
6994
  }
@@ -6976,12 +6996,12 @@ class WebRTCClient extends Emitter {
6976
6996
  return this.userAgent.stop().then(() => {
6977
6997
  return this._cleanupRegister();
6978
6998
  }).catch(e => {
6979
- logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6999
+ logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6980
7000
  });
6981
7001
  }
6982
7002
 
6983
7003
  call(number , enableVideo , audioOnly = false, conference = false) {
6984
- logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
7004
+ logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6985
7005
  const inviterOptions = {
6986
7006
  sessionDescriptionHandlerOptionsReInvite: {
6987
7007
  conference,
@@ -7012,7 +7032,7 @@ class WebRTCClient extends Emitter {
7012
7032
  this._onAccepted(session, response.session, true);
7013
7033
  },
7014
7034
  onReject: (response ) => {
7015
- logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7035
+ logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7016
7036
  this._stopSendingStats(session);
7017
7037
  this.stopNetworkMonitoring(session);
7018
7038
 
@@ -7035,11 +7055,11 @@ class WebRTCClient extends Emitter {
7035
7055
  }
7036
7056
 
7037
7057
  answer(session , enableVideo ) {
7038
- logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
7058
+ logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
7039
7059
 
7040
7060
  if (!session || !session.accept) {
7041
7061
  const error = 'No session to answer, or not an invitation';
7042
- logger$4.warn(error);
7062
+ logger$8.warn(error);
7043
7063
  return Promise.reject(new Error(error));
7044
7064
  }
7045
7065
  const options = {
@@ -7049,15 +7069,15 @@ class WebRTCClient extends Emitter {
7049
7069
  return session.accept(options).then(() => {
7050
7070
  if (session.isCanceled) {
7051
7071
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
7052
- logger$4.error(message, { id: session.id });
7072
+ logger$8.error(message, { id: session.id });
7053
7073
  this.onCallEnded(session);
7054
7074
 
7055
7075
  throw new CanceledCallError(message);
7056
7076
  }
7057
- logger$4.info('sdk webrtc answer, accepted.');
7077
+ logger$8.info('sdk webrtc answer, accepted.');
7058
7078
  this._onAccepted(session);
7059
7079
  }).catch(e => {
7060
- logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7080
+ logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7061
7081
 
7062
7082
  throw e;
7063
7083
  });
@@ -7065,7 +7085,7 @@ class WebRTCClient extends Emitter {
7065
7085
 
7066
7086
  hangup(session ) {
7067
7087
  const { state, id } = session;
7068
- logger$4.info('sdk webrtc hangup call', { id, state });
7088
+ logger$8.info('sdk webrtc hangup call', { id, state });
7069
7089
 
7070
7090
  try {
7071
7091
  this._stopSendingStats(session);
@@ -7094,7 +7114,7 @@ class WebRTCClient extends Emitter {
7094
7114
 
7095
7115
  return bye();
7096
7116
  } catch (error) {
7097
- logger$4.warn('sdk webrtc hangup, error', error);
7117
+ logger$8.warn('sdk webrtc hangup, error', error);
7098
7118
  }
7099
7119
 
7100
7120
  return null;
@@ -7112,7 +7132,7 @@ class WebRTCClient extends Emitter {
7112
7132
  // Fetch and emit an event at `interval` with session network stats
7113
7133
  startNetworkMonitoring(session , interval = 1000) {
7114
7134
  const sessionId = this.getSipSessionId(session);
7115
- logger$4.info('starting network inspection', { id: sessionId });
7135
+ logger$8.info('starting network inspection', { id: sessionId });
7116
7136
 
7117
7137
  this.sessionNetworkStats[sessionId] = [];
7118
7138
 
@@ -7122,7 +7142,7 @@ class WebRTCClient extends Emitter {
7122
7142
  stopNetworkMonitoring(session ) {
7123
7143
  const sessionId = this.getSipSessionId(session);
7124
7144
  const exists = sessionId in this.networkMonitoringInterval;
7125
- logger$4.info('stopping network inspection', { id: sessionId, exists });
7145
+ logger$8.info('stopping network inspection', { id: sessionId, exists });
7126
7146
 
7127
7147
  if (exists) {
7128
7148
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -7132,17 +7152,17 @@ class WebRTCClient extends Emitter {
7132
7152
  }
7133
7153
 
7134
7154
  reject(session ) {
7135
- logger$4.info('sdk webrtc reject call', { id: session.id });
7155
+ logger$8.info('sdk webrtc reject call', { id: session.id });
7136
7156
 
7137
7157
  try {
7138
7158
  return session.reject ? session.reject() : session.cancel();
7139
7159
  } catch (e) {
7140
- logger$4.warn('Error when rejecting call', e.message, e.stack);
7160
+ logger$8.warn('Error when rejecting call', e.message, e.stack);
7141
7161
  }
7142
7162
  }
7143
7163
 
7144
7164
  async close() {
7145
- logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7165
+ logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7146
7166
  this._cleanupMedia();
7147
7167
  this.connectionPromise = null;
7148
7168
 
@@ -7173,7 +7193,7 @@ class WebRTCClient extends Emitter {
7173
7193
  // eg: "INVITE not rejectable in state Completed"
7174
7194
  }
7175
7195
  this.userAgent = null;
7176
- logger$4.info('sdk webrtc client closed');
7196
+ logger$8.info('sdk webrtc client closed');
7177
7197
  }
7178
7198
 
7179
7199
  getNumber(session ) {
@@ -7186,13 +7206,13 @@ class WebRTCClient extends Emitter {
7186
7206
  }
7187
7207
 
7188
7208
  mute(session ) {
7189
- logger$4.info('sdk webrtc mute', { id: session.id });
7209
+ logger$8.info('sdk webrtc mute', { id: session.id });
7190
7210
 
7191
7211
  this._toggleAudio(session, true);
7192
7212
  }
7193
7213
 
7194
7214
  unmute(session ) {
7195
- logger$4.info('sdk webrtc unmute', { id: session.id });
7215
+ logger$8.info('sdk webrtc unmute', { id: session.id });
7196
7216
 
7197
7217
  this._toggleAudio(session, false);
7198
7218
  }
@@ -7232,13 +7252,13 @@ class WebRTCClient extends Emitter {
7232
7252
  }
7233
7253
 
7234
7254
  toggleCameraOn(session ) {
7235
- logger$4.info('sdk webrtc toggle camera on', { id: session.id });
7255
+ logger$8.info('sdk webrtc toggle camera on', { id: session.id });
7236
7256
 
7237
7257
  this._toggleVideo(session, false);
7238
7258
  }
7239
7259
 
7240
7260
  toggleCameraOff(session ) {
7241
- logger$4.info('sdk webrtc toggle camera off', { id: session.id });
7261
+ logger$8.info('sdk webrtc toggle camera off', { id: session.id });
7242
7262
 
7243
7263
  this._toggleVideo(session, true);
7244
7264
  }
@@ -7247,7 +7267,7 @@ class WebRTCClient extends Emitter {
7247
7267
  const sessionId = this.getSipSessionId(session);
7248
7268
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
7249
7269
 
7250
- logger$4.info('sdk webrtc hold', {
7270
+ logger$8.info('sdk webrtc hold', {
7251
7271
  sessionId,
7252
7272
  keys: Object.keys(this.heldSessions),
7253
7273
  pendingReinvite: !!session.pendingReinvite,
@@ -7296,7 +7316,7 @@ class WebRTCClient extends Emitter {
7296
7316
  const sessionId = this.getSipSessionId(session);
7297
7317
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7298
7318
 
7299
- logger$4.info('sdk webrtc unhold', {
7319
+ logger$8.info('sdk webrtc unhold', {
7300
7320
  sessionId,
7301
7321
  keys: Object.keys(this.heldSessions),
7302
7322
  pendingReinvite: !!session.pendingReinvite,
@@ -7444,7 +7464,7 @@ class WebRTCClient extends Emitter {
7444
7464
  if (!session.sessionDescriptionHandler) {
7445
7465
  return;
7446
7466
  }
7447
- logger$4.info('Sending DTMF', {
7467
+ logger$8.info('Sending DTMF', {
7448
7468
  id: this.getSipSessionId(session),
7449
7469
  tone,
7450
7470
  });
@@ -7460,7 +7480,7 @@ class WebRTCClient extends Emitter {
7460
7480
  transfer(session , target ) {
7461
7481
  this.hold(session);
7462
7482
 
7463
- logger$4.info('Transfering a session', {
7483
+ logger$8.info('Transfering a session', {
7464
7484
  id: this.getSipSessionId(session),
7465
7485
  target,
7466
7486
  });
@@ -7482,17 +7502,17 @@ class WebRTCClient extends Emitter {
7482
7502
  atxfer(session ) {
7483
7503
  this.hold(session);
7484
7504
 
7485
- logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7505
+ logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7486
7506
 
7487
7507
  const result = {
7488
7508
  newSession: null,
7489
7509
  init: async (target ) => {
7490
- logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7510
+ logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7491
7511
 
7492
7512
  result.newSession = await this.call(target);
7493
7513
  },
7494
7514
  complete: () => {
7495
- logger$4.info('webrtc transfer completed', {
7515
+ logger$8.info('webrtc transfer completed', {
7496
7516
  id: this.getSipSessionId(session),
7497
7517
  referId: this.getSipSessionId(result.newSession),
7498
7518
  });
@@ -7513,7 +7533,7 @@ class WebRTCClient extends Emitter {
7513
7533
  return;
7514
7534
  }
7515
7535
 
7516
- logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
7536
+ logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7517
7537
 
7518
7538
  try {
7519
7539
  sipSession.message({
@@ -7555,7 +7575,7 @@ class WebRTCClient extends Emitter {
7555
7575
  }
7556
7576
 
7557
7577
  changeAudioOutputVolume(volume ) {
7558
- logger$4.info('Changing audio output volume', { volume });
7578
+ logger$8.info('Changing audio output volume', { volume });
7559
7579
 
7560
7580
  Object.values(this.audioElements).forEach(audioElement => {
7561
7581
  if (audioElement instanceof HTMLAudioElement) {
@@ -7567,7 +7587,7 @@ class WebRTCClient extends Emitter {
7567
7587
  }
7568
7588
 
7569
7589
  changeAudioOutputDevice(id ) {
7570
- logger$4.info('Changing audio output device', { id });
7590
+ logger$8.info('Changing audio output device', { id });
7571
7591
 
7572
7592
  Object.values(this.audioElements).forEach(audioElement => {
7573
7593
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7584,7 +7604,7 @@ class WebRTCClient extends Emitter {
7584
7604
 
7585
7605
  changeAudioInputDevice(id , session ) {
7586
7606
  const currentId = this.getAudioDeviceId();
7587
- logger$4.info('setting audio input device', { id, currentId, session: !!session });
7607
+ logger$8.info('setting audio input device', { id, currentId, session: !!session });
7588
7608
 
7589
7609
  if (id === currentId) {
7590
7610
  return null;
@@ -7630,7 +7650,7 @@ class WebRTCClient extends Emitter {
7630
7650
 
7631
7651
  setVideoInputDevice(id ) {
7632
7652
  const currentId = this.getVideoDeviceId();
7633
- logger$4.info('setting video input device', { id, currentId });
7653
+ logger$8.info('setting video input device', { id, currentId });
7634
7654
 
7635
7655
  if (id === currentId) {
7636
7656
  return null;
@@ -7655,7 +7675,7 @@ class WebRTCClient extends Emitter {
7655
7675
  const sessionId = this.getSipSessionId(session);
7656
7676
  const localStream = this.getLocalStream(sessionId);
7657
7677
 
7658
- logger$4.info('changing video input device', { id, sessionId });
7678
+ logger$8.info('changing video input device', { id, sessionId });
7659
7679
 
7660
7680
  // Release old video stream
7661
7681
  if (localStream) {
@@ -7723,7 +7743,7 @@ class WebRTCClient extends Emitter {
7723
7743
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7724
7744
  const desktop = newConstraints && newConstraints.desktop;
7725
7745
 
7726
- logger$4.info('Sending reinvite', {
7746
+ logger$8.info('Sending reinvite', {
7727
7747
  id: this.getSipSessionId(sipSession),
7728
7748
  newConstraints,
7729
7749
  conference,
@@ -7761,7 +7781,7 @@ class WebRTCClient extends Emitter {
7761
7781
  sipSession.incomingInviteRequest.message.body = response.message.body;
7762
7782
  }
7763
7783
 
7764
- logger$4.info('on re-INVITE accepted', {
7784
+ logger$8.info('on re-INVITE accepted', {
7765
7785
  id: this.getSipSessionId(sipSession),
7766
7786
  wasMuted,
7767
7787
  shouldDoScreenSharing,
@@ -7779,7 +7799,7 @@ class WebRTCClient extends Emitter {
7779
7799
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7780
7800
  }
7781
7801
 
7782
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7802
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7783
7803
  },
7784
7804
  },
7785
7805
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7936,7 +7956,7 @@ class WebRTCClient extends Emitter {
7936
7956
  }
7937
7957
 
7938
7958
  startHeartbeat() {
7939
- logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7959
+ logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7940
7960
  if (!this.userAgent) {
7941
7961
  this.heartbeat.stop();
7942
7962
  return;
@@ -7949,7 +7969,7 @@ class WebRTCClient extends Emitter {
7949
7969
  }
7950
7970
 
7951
7971
  stopHeartbeat() {
7952
- logger$4.info('sdk webrtc stop heartbeat');
7972
+ logger$8.info('sdk webrtc stop heartbeat');
7953
7973
  this.heartbeat.stop();
7954
7974
  }
7955
7975
 
@@ -7970,7 +7990,7 @@ class WebRTCClient extends Emitter {
7970
7990
  }
7971
7991
 
7972
7992
  attemptReconnection() {
7973
- logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
7993
+ logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7974
7994
  if (!this.userAgent) {
7975
7995
  return;
7976
7996
  }
@@ -7995,7 +8015,7 @@ class WebRTCClient extends Emitter {
7995
8015
  return;
7996
8016
  }
7997
8017
 
7998
- logger$4.info('setting local media stream', {
8018
+ logger$8.info('setting local media stream', {
7999
8019
  sipSessionId,
8000
8020
  tracks: newStream ? newStream.getTracks() : null,
8001
8021
  });
@@ -8012,7 +8032,7 @@ class WebRTCClient extends Emitter {
8012
8032
 
8013
8033
  const oldStream = this.getLocalStream(sipSessionId);
8014
8034
 
8015
- logger$4.info('updating local stream', {
8035
+ logger$8.info('updating local stream', {
8016
8036
  sipSessionId,
8017
8037
  oldStream: !!oldStream,
8018
8038
  tracks: newStream.getTracks(),
@@ -8032,7 +8052,7 @@ class WebRTCClient extends Emitter {
8032
8052
  const remoteStream = this.getRemoteStream(sessionId);
8033
8053
  const pc = this.getPeerConnection(sessionId);
8034
8054
 
8035
- logger$4.info('Updating remote stream', {
8055
+ logger$8.info('Updating remote stream', {
8036
8056
  sessionId,
8037
8057
  tracks: remoteStream ? remoteStream.getTracks() : null,
8038
8058
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -8057,14 +8077,16 @@ class WebRTCClient extends Emitter {
8057
8077
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
8058
8078
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
8059
8079
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
8080
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
8060
8081
 
8061
- logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8082
+ logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8062
8083
 
8063
8084
  return {
8064
8085
  constraints: {
8065
8086
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
8066
8087
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
8067
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
8088
+ video: screenSharing ? (isDesktop
8089
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
8068
8090
  : this._getVideoConstraints(enableVideo),
8069
8091
  screen: screenSharing,
8070
8092
  desktop: isDesktop,
@@ -8107,7 +8129,7 @@ class WebRTCClient extends Emitter {
8107
8129
  }
8108
8130
 
8109
8131
  _onTransportError() {
8110
- logger$4.error('on transport error');
8132
+ logger$8.error('on transport error');
8111
8133
  this.eventEmitter.emit(TRANSPORT_ERROR);
8112
8134
  this.attemptReconnection();
8113
8135
  }
@@ -8116,7 +8138,7 @@ class WebRTCClient extends Emitter {
8116
8138
  const body = message && typeof message === 'object' ? message.data : message;
8117
8139
  if (body && body.indexOf('200 OK') !== -1) {
8118
8140
  if (this.hasHeartbeat()) {
8119
- logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8141
+ logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8120
8142
 
8121
8143
  this.heartbeat.onHeartbeat();
8122
8144
  if (this.heartbeatCb) {
@@ -8127,7 +8149,7 @@ class WebRTCClient extends Emitter {
8127
8149
  }
8128
8150
 
8129
8151
  async _onHeartbeatTimeout() {
8130
- logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8152
+ logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8131
8153
 
8132
8154
  if (this.heartbeatTimeoutCb) {
8133
8155
  this.heartbeatTimeoutCb();
@@ -8139,7 +8161,7 @@ class WebRTCClient extends Emitter {
8139
8161
  try {
8140
8162
  await this.userAgent.transport.disconnect();
8141
8163
  } catch (e) {
8142
- logger$4.error('Transport disconnection after heartbeat timeout, error', e);
8164
+ logger$8.error('Transport disconnection after heartbeat timeout, error', e);
8143
8165
  }
8144
8166
  }
8145
8167
 
@@ -8172,31 +8194,31 @@ class WebRTCClient extends Emitter {
8172
8194
  }
8173
8195
 
8174
8196
  _connectIfNeeded() {
8175
- logger$4.info('connect if needed, checking', { connected: this.isConnected() });
8197
+ logger$8.info('connect if needed, checking', { connected: this.isConnected() });
8176
8198
  if (!this.userAgent) {
8177
- logger$4.info('need to recreate User Agent');
8199
+ logger$8.info('need to recreate User Agent');
8178
8200
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
8179
8201
  }
8180
8202
 
8181
8203
  if (this.isConnected()) {
8182
- logger$4.info('webrtc sdk, already connected');
8204
+ logger$8.info('webrtc sdk, already connected');
8183
8205
  return Promise.resolve();
8184
8206
  }
8185
8207
 
8186
8208
  if (this.isConnecting()) {
8187
- logger$4.info('webrtc sdk, already connecting...');
8209
+ logger$8.info('webrtc sdk, already connecting...');
8188
8210
 
8189
8211
  this.connectionPromise = this.userAgent.transport.connectPromise;
8190
8212
  return this.connectionPromise;
8191
8213
  }
8192
8214
 
8193
8215
  if (this.connectionPromise) {
8194
- logger$4.info('webrtc sdk, connection promise connecting...');
8216
+ logger$8.info('webrtc sdk, connection promise connecting...');
8195
8217
  // $FlowFixMe
8196
8218
  return this.connectionPromise;
8197
8219
  }
8198
8220
 
8199
- logger$4.info('WebRTC UA needs to connect');
8221
+ logger$8.info('WebRTC UA needs to connect');
8200
8222
 
8201
8223
  // Force UA to reconnect
8202
8224
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8321,7 +8343,7 @@ class WebRTCClient extends Emitter {
8321
8343
 
8322
8344
  sdh.peerConnectionDelegate = {
8323
8345
  onicecandidateerror: (error ) => {
8324
- logger$4.error('on icecandidate error', {
8346
+ logger$8.error('on icecandidate error', {
8325
8347
  address: error.address,
8326
8348
  port: error.port,
8327
8349
  errorCode: error.errorCode,
@@ -8350,7 +8372,7 @@ class WebRTCClient extends Emitter {
8350
8372
  updatedNumber = session.assertedIdentity.uri.normal.user;
8351
8373
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8352
8374
  }
8353
- logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8375
+ logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8354
8376
 
8355
8377
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8356
8378
 
@@ -8366,12 +8388,12 @@ class WebRTCClient extends Emitter {
8366
8388
 
8367
8389
  this._setupMedias(session);
8368
8390
 
8369
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8391
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8370
8392
  };
8371
8393
  }
8372
8394
 
8373
8395
  _onAccepted(session , sessionDialog , withEvent = true) {
8374
- logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8396
+ logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8375
8397
 
8376
8398
  this.storeSipSession(session);
8377
8399
 
@@ -8383,14 +8405,14 @@ class WebRTCClient extends Emitter {
8383
8405
  const onTrack = (event ) => {
8384
8406
  const isAudioOnly = this._isAudioOnly(session);
8385
8407
  const { kind, label, readyState, id, muted } = event.track;
8386
- logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8408
+ logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8387
8409
 
8388
8410
  // Stop video track in audio only mode
8389
8411
  if (isAudioOnly && kind === 'video') {
8390
8412
  event.track.stop();
8391
8413
  }
8392
8414
 
8393
- this.eventEmitter.emit(ON_TRACK, session, event);
8415
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
8394
8416
  };
8395
8417
 
8396
8418
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8399,12 +8421,14 @@ class WebRTCClient extends Emitter {
8399
8421
 
8400
8422
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8401
8423
 
8402
- pc.oniceconnectionstatechange = () => {
8403
- logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
8404
- if (pc.iceConnectionState === 'disconnected') {
8405
- this.eventEmitter.emit(ON_DISCONNECTED);
8406
- }
8407
- };
8424
+ if (pc) {
8425
+ pc.oniceconnectionstatechange = () => {
8426
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8427
+ if (pc.iceConnectionState === 'disconnected') {
8428
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8429
+ }
8430
+ };
8431
+ }
8408
8432
 
8409
8433
  if (withEvent) {
8410
8434
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8573,10 +8597,10 @@ class WebRTCClient extends Emitter {
8573
8597
 
8574
8598
  _stopSendingStats(session ) {
8575
8599
  const sessionId = this.getSipSessionId(session);
8576
- logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8600
+ logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8577
8601
 
8578
8602
  if (sessionId in this.statsIntervals) {
8579
- logger$4.trace('Stop sending stats for call', { sessionId });
8603
+ logger$8.trace('Stop sending stats for call', { sessionId });
8580
8604
  this.statsIntervals[sessionId]();
8581
8605
  delete this.statsIntervals[sessionId];
8582
8606
  }
@@ -8592,7 +8616,7 @@ class WebRTCClient extends Emitter {
8592
8616
  try {
8593
8617
  await this.userAgent.transport.disconnect();
8594
8618
  } catch (e) {
8595
- logger$4.error('WebRTC transport disconnect, error', e);
8619
+ logger$8.error('WebRTC transport disconnect, error', e);
8596
8620
  }
8597
8621
  }
8598
8622
  }
@@ -8614,13 +8638,17 @@ class WebRTCClient extends Emitter {
8614
8638
  const nbStats = this.sessionNetworkStats[sessionId].length;
8615
8639
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8616
8640
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8641
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8617
8642
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8618
8643
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8644
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8619
8645
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8620
8646
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8621
8647
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8622
- let audioBytesSent = 0;
8623
- let audioBytesReceived = 0;
8648
+ let audioBytesSent = 0; // content + header
8649
+ let audioBytesReceived = 0; // content + header
8650
+ let audioContentSent = 0; // useful to detect blank call
8651
+ let audioContentReceived = 0;
8624
8652
  let videoBytesSent = 0;
8625
8653
  let videoBytesReceived = 0;
8626
8654
  let transportSent = 0;
@@ -8630,6 +8658,7 @@ class WebRTCClient extends Emitter {
8630
8658
  stats.forEach(report => {
8631
8659
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8632
8660
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8661
+ audioContentSent += Number(report.bytesSent);
8633
8662
  }
8634
8663
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8635
8664
  audioBytesSent += Number(report.bytesSent);
@@ -8641,6 +8670,7 @@ class WebRTCClient extends Emitter {
8641
8670
  packetsLost += Number(report.packetsLost);
8642
8671
  networkStats.packetsReceived = Number(report.packetsReceived);
8643
8672
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8673
+ audioContentReceived += Number(report.bytesReceived);
8644
8674
  }
8645
8675
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8646
8676
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8669,10 +8699,17 @@ class WebRTCClient extends Emitter {
8669
8699
  });
8670
8700
 
8671
8701
  networkStats.packetsLost = packetsLost;
8702
+
8672
8703
  networkStats.totalAudioBytesSent = audioBytesSent;
8673
8704
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8674
8705
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8675
8706
  networkStats.audioBytesReceived = audioBytesReceived;
8707
+
8708
+ networkStats.totalAudioContentSent = audioContentSent;
8709
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8710
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8711
+ networkStats.audioContentReceived = audioContentReceived;
8712
+
8676
8713
  networkStats.totalVideoBytesSent = videoBytesSent;
8677
8714
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8678
8715
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8686,7 +8723,7 @@ class WebRTCClient extends Emitter {
8686
8723
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8687
8724
  + networkStats.transportSent;
8688
8725
 
8689
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8726
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8690
8727
  this.sessionNetworkStats[sessionId].push(networkStats);
8691
8728
  }
8692
8729
 
@@ -8711,11 +8748,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8711
8748
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8712
8749
  const ON_CALL_CANCELED = 'onCallCanceled';
8713
8750
  const ON_CALL_FAILED = 'onCallFailed';
8751
+ const ON_CALL_REJECTED = 'onCallRejected';
8714
8752
  const ON_CALL_ENDED = 'onCallEnded';
8715
8753
  const ON_CALL_ENDING = 'onCallEnding';
8716
8754
  const ON_MESSAGE = 'onMessage';
8717
- const ON_REINVITE$1 = 'reinvite';
8718
- const ON_TRACK$1 = 'onTrack';
8755
+ const ON_REINVITE = 'reinvite';
8756
+ const ON_TRACK = 'onTrack';
8719
8757
  const ON_AUDIO_STREAM = 'onAudioStream';
8720
8758
  const ON_VIDEO_STREAM = 'onVideoStream';
8721
8759
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8730,15 +8768,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8730
8768
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8731
8769
  const ON_CALL_ERROR = 'onCallError';
8732
8770
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8733
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
8771
+ const ON_NETWORK_STATS = 'onNetworkStats';
8734
8772
  const ON_CHAT = 'phone/ON_CHAT';
8735
8773
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8736
- const ON_DISCONNECTED$1 = 'onDisconnected';
8774
+ const ON_DISCONNECTED = 'onDisconnected';
8737
8775
 
8738
8776
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8739
8777
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8740
8778
 
8741
- const events$1 = [
8779
+ const events = [
8742
8780
  ON_USER_AGENT,
8743
8781
  ON_REGISTERED,
8744
8782
  ON_UNREGISTERED,
@@ -8755,9 +8793,10 @@ const events$1 = [
8755
8793
  ON_CAMERA_DISABLED,
8756
8794
  ON_CALL_FAILED,
8757
8795
  ON_CALL_ENDED,
8796
+ ON_CALL_REJECTED,
8758
8797
  ON_MESSAGE,
8759
- ON_REINVITE$1,
8760
- ON_TRACK$1,
8798
+ ON_REINVITE,
8799
+ ON_TRACK,
8761
8800
  ON_AUDIO_STREAM,
8762
8801
  ON_VIDEO_STREAM,
8763
8802
  ON_REMOVE_STREAM,
@@ -8772,11 +8811,11 @@ const events$1 = [
8772
8811
  ON_CALL_ERROR,
8773
8812
  ON_CHAT,
8774
8813
  ON_SIGNAL,
8775
- ON_NETWORK_STATS$1,
8776
- ON_DISCONNECTED$1,
8814
+ ON_NETWORK_STATS,
8815
+ ON_DISCONNECTED,
8777
8816
  ];
8778
8817
 
8779
- const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
8818
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8780
8819
 
8781
8820
  class WebRTCPhone extends Emitter {
8782
8821
 
@@ -8849,7 +8888,7 @@ class WebRTCPhone extends Emitter {
8849
8888
  }).catch(error => {
8850
8889
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8851
8890
  console.error('register error', error, error.message, error.stack);
8852
- logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
8891
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8853
8892
  });
8854
8893
  }
8855
8894
 
@@ -8864,7 +8903,7 @@ class WebRTCPhone extends Emitter {
8864
8903
  if (!this.client) {
8865
8904
  return;
8866
8905
  }
8867
- logger$5.info('WebRTC phone stop');
8906
+ logger$7.info('WebRTC phone stop');
8868
8907
  this.client.stop();
8869
8908
  }
8870
8909
 
@@ -8879,11 +8918,12 @@ class WebRTCPhone extends Emitter {
8879
8918
  async sendReinvite(callSession , constraints = null, conference = false,
8880
8919
  audioOnly = false, iceRestart = false) {
8881
8920
  const sipSession = this.findSipSession(callSession);
8882
- logger$5.info('WebRTC phone - send reinvite', {
8921
+ logger$7.info('WebRTC phone - send reinvite', {
8883
8922
  sessionId: sipSession ? sipSession.id : null,
8884
8923
  constraints,
8885
8924
  audioOnly,
8886
8925
  conference,
8926
+ iceRestart,
8887
8927
  });
8888
8928
 
8889
8929
  if (!sipSession) {
@@ -8916,7 +8956,7 @@ class WebRTCPhone extends Emitter {
8916
8956
  }
8917
8957
 
8918
8958
  startHeartbeat() {
8919
- logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8959
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8920
8960
  if (!this.client || this.client.hasHeartbeat()) {
8921
8961
  return;
8922
8962
  }
@@ -8925,7 +8965,7 @@ class WebRTCPhone extends Emitter {
8925
8965
  }
8926
8966
 
8927
8967
  stopHeartbeat() {
8928
- logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8968
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8929
8969
  if (!this.client) {
8930
8970
  return;
8931
8971
  }
@@ -8942,7 +8982,7 @@ class WebRTCPhone extends Emitter {
8942
8982
  }
8943
8983
 
8944
8984
  reconnect() {
8945
- logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
8985
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8946
8986
  if (!this.client) {
8947
8987
  return;
8948
8988
  }
@@ -8983,7 +9023,7 @@ class WebRTCPhone extends Emitter {
8983
9023
  return false;
8984
9024
  }
8985
9025
 
8986
- logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9026
+ logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8987
9027
 
8988
9028
  this.client.downgradeToAudio(sipSession);
8989
9029
 
@@ -9006,7 +9046,7 @@ class WebRTCPhone extends Emitter {
9006
9046
  return Promise.resolve(false);
9007
9047
  }
9008
9048
 
9009
- logger$5.info('Upgrade to video', {
9049
+ logger$7.info('Upgrade to video', {
9010
9050
  id: callSession ? callSession.getId() : null,
9011
9051
  constraints,
9012
9052
  isConference,
@@ -9046,7 +9086,7 @@ class WebRTCPhone extends Emitter {
9046
9086
 
9047
9087
  _sendReinviteMessage(callSession , isUpgrade ) {
9048
9088
  const sipSession = this.findSipSession(callSession);
9049
- logger$5.info('Sending reinvite message', {
9089
+ logger$7.info('Sending reinvite message', {
9050
9090
  id: callSession ? callSession.getId() : null,
9051
9091
  isUpgrade,
9052
9092
  });
@@ -9072,7 +9112,7 @@ class WebRTCPhone extends Emitter {
9072
9112
  // Monkey patch to know when canceled with the CANCEL message
9073
9113
  const onCancel = sipSession._onCancel.bind(sipSession);
9074
9114
  sipSession._onCancel = (message ) => {
9075
- logger$5.trace('on sip session canceled', { callId: message.callId });
9115
+ logger$7.trace('on sip session canceled', { callId: message.callId });
9076
9116
 
9077
9117
  onCancel(message);
9078
9118
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -9100,16 +9140,17 @@ class WebRTCPhone extends Emitter {
9100
9140
  this.audioOutputVolume,
9101
9141
  );
9102
9142
  case sessionState.SessionState.Terminating:
9103
- logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9143
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9104
9144
 
9105
9145
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9106
9146
 
9107
9147
  break;
9108
9148
  case sessionState.SessionState.Terminated: {
9109
- logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9149
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9110
9150
 
9111
9151
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9112
9152
  const callSession = this._createCallSession(sipSession);
9153
+ callSession.endTime = new Date();
9113
9154
  const wasCurrentSession = this._onCallTerminated(sipSession);
9114
9155
 
9115
9156
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9128,7 +9169,7 @@ class WebRTCPhone extends Emitter {
9128
9169
  const [stream] = event.streams;
9129
9170
  const kind = event && event.track && event.track.kind;
9130
9171
 
9131
- logger$5.info('on track stream called on the peer connection', {
9172
+ logger$7.info('on track stream called on the peer connection', {
9132
9173
  callId: this.getSipSessionId(sipSession),
9133
9174
  streamId: stream ? stream.id : null,
9134
9175
  tracks: stream ? stream.getTracks() : null,
@@ -9148,7 +9189,7 @@ class WebRTCPhone extends Emitter {
9148
9189
  };
9149
9190
 
9150
9191
  peerConnection.onremovestream = event => {
9151
- logger$5.info('on remove stream called on the peer connection', {
9192
+ logger$7.info('on remove stream called on the peer connection', {
9152
9193
  id: event.stream.id,
9153
9194
  tracks: event.stream.getTracks(),
9154
9195
  });
@@ -9158,7 +9199,7 @@ class WebRTCPhone extends Emitter {
9158
9199
  }
9159
9200
 
9160
9201
  async startScreenSharing(constraints , callSession ) {
9161
- logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9202
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9162
9203
 
9163
9204
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9164
9205
  if (!screenShareStream) {
@@ -9198,7 +9239,7 @@ class WebRTCPhone extends Emitter {
9198
9239
  return;
9199
9240
  }
9200
9241
 
9201
- logger$5.info('WebRTC phone - stop screen sharing', {
9242
+ logger$7.info('WebRTC phone - stop screen sharing', {
9202
9243
  restoreLocalStream,
9203
9244
  });
9204
9245
 
@@ -9254,7 +9295,7 @@ class WebRTCPhone extends Emitter {
9254
9295
  const pc = this.client.getPeerConnection(sipSessionId);
9255
9296
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9256
9297
 
9257
- logger$5.info('WebRTC phone - on screensharing', {
9298
+ logger$7.info('WebRTC phone - on screensharing', {
9258
9299
  hadVideo,
9259
9300
  id: this.getSipSessionId(sipSession),
9260
9301
  screenTrack,
@@ -9262,7 +9303,7 @@ class WebRTCPhone extends Emitter {
9262
9303
 
9263
9304
  if (screenTrack) {
9264
9305
  screenTrack.onended = () => {
9265
- logger$5.info('WebRTC phone - on screenshare ended', {
9306
+ logger$7.info('WebRTC phone - on screenshare ended', {
9266
9307
  hadVideo,
9267
9308
  id: this.getSipSessionId(sipSession),
9268
9309
  screenTrack,
@@ -9293,7 +9334,7 @@ class WebRTCPhone extends Emitter {
9293
9334
  }
9294
9335
 
9295
9336
  _onCallAccepted(sipSession , cameraEnabled ) {
9296
- logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9337
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9297
9338
 
9298
9339
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9299
9340
  this.currentSipSession = sipSession;
@@ -9311,7 +9352,7 @@ class WebRTCPhone extends Emitter {
9311
9352
  }
9312
9353
 
9313
9354
  changeAudioDevice(id ) {
9314
- logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9355
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9315
9356
  this.audioOutputDeviceId = id;
9316
9357
  this.client.changeAudioOutputDevice(id);
9317
9358
  }
@@ -9321,14 +9362,14 @@ class WebRTCPhone extends Emitter {
9321
9362
  }
9322
9363
 
9323
9364
  changeRingDevice(id ) {
9324
- logger$5.info('WebRTC phone - changing ring device', { id });
9365
+ logger$7.info('WebRTC phone - changing ring device', { id });
9325
9366
 
9326
9367
  this.audioRingDeviceId = id;
9327
9368
  }
9328
9369
 
9329
9370
  // volume is a value between 0 and 1
9330
9371
  changeAudioVolume(volume ) {
9331
- logger$5.info('WebRTC phone - changing audio volume', { volume });
9372
+ logger$7.info('WebRTC phone - changing audio volume', { volume });
9332
9373
 
9333
9374
  this.audioOutputVolume = volume;
9334
9375
  this.client.changeAudioOutputVolume(volume);
@@ -9336,32 +9377,33 @@ class WebRTCPhone extends Emitter {
9336
9377
 
9337
9378
  // volume is a value between 0 and 1
9338
9379
  changeRingVolume(volume ) {
9339
- logger$5.info('WebRTC phone - changing ring volume', { volume });
9380
+ logger$7.info('WebRTC phone - changing ring volume', { volume });
9340
9381
 
9341
9382
  this.audioRingVolume = volume;
9342
9383
  }
9343
9384
 
9344
9385
  changeAudioInputDevice(id ) {
9345
- logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9386
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9346
9387
 
9347
9388
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9348
9389
  }
9349
9390
 
9350
9391
  changeVideoInputDevice(id ) {
9351
- logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9392
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9352
9393
 
9353
9394
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9354
9395
  }
9355
9396
 
9356
9397
  changeSessionVideoInputDevice(id ) {
9357
- logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9398
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9358
9399
 
9359
9400
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9360
9401
  }
9361
9402
 
9362
9403
  _onCallTerminated(sipSession ) {
9363
- logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9404
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9364
9405
 
9406
+ const sipSessionId = this.getSipSessionId(sipSession);
9365
9407
  const callSession = this._createCallSession(sipSession);
9366
9408
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9367
9409
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9379,7 +9421,6 @@ class WebRTCPhone extends Emitter {
9379
9421
  }, 5);
9380
9422
  }
9381
9423
 
9382
- const sipSessionId = this.getSipSessionId(sipSession);
9383
9424
  if (sipSessionId) {
9384
9425
  this.removeIncomingSessions(sipSessionId);
9385
9426
  }
@@ -9394,7 +9435,7 @@ class WebRTCPhone extends Emitter {
9394
9435
  const hasIncomingCallSession = this.hasIncomingCallSession();
9395
9436
 
9396
9437
  // Re-trigger incoming call event for remaining incoming calls
9397
- logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9438
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9398
9439
  sipId: sipSession.id,
9399
9440
  shouldRetrigger,
9400
9441
  hasIncomingCallSession,
@@ -9485,37 +9526,37 @@ class WebRTCPhone extends Emitter {
9485
9526
 
9486
9527
  // Deprecated
9487
9528
  getLocalStreamForCall(callSession ) {
9488
- logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9529
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9489
9530
 
9490
9531
  return this.getLocalStream(callSession);
9491
9532
  }
9492
9533
 
9493
9534
  // Deprecated
9494
9535
  getRemoteStreamForCall(callSession ) {
9495
- logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9536
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9496
9537
 
9497
9538
  return this.getRemoteVideoStream(callSession);
9498
9539
  }
9499
9540
 
9500
9541
  getRemoteStreamsForCall(callSession ) {
9501
- logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9542
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9502
9543
 
9503
9544
  return this.getRemoteStream(callSession);
9504
9545
  }
9505
9546
 
9506
9547
  accept(callSession , cameraEnabled ) {
9507
- logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9548
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9508
9549
  if (this.currentSipSession) {
9509
9550
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9510
9551
  }
9511
9552
 
9512
9553
  if (!callSession) {
9513
- logger$5.warn('no CallSession to accept.');
9554
+ logger$7.warn('no CallSession to accept.');
9514
9555
  return Promise.resolve(null);
9515
9556
  }
9516
9557
 
9517
9558
  if (callSession.getId() in this.acceptedSessions) {
9518
- logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9559
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9519
9560
  return Promise.resolve(callSession.sipCallId);
9520
9561
  }
9521
9562
 
@@ -9527,24 +9568,24 @@ class WebRTCPhone extends Emitter {
9527
9568
  const sipSession = this.client.getSipSession(callSession.getId());
9528
9569
  if (sipSession) {
9529
9570
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9530
- logger$5.warn('Trying to answer a terminated sipSession.');
9571
+ logger$7.warn('Trying to answer a terminated sipSession.');
9531
9572
 
9532
9573
  return Promise.resolve(null);
9533
9574
  }
9534
9575
 
9535
- logger$5.info('accept call, session found', { sipId: sipSession.id });
9576
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
9536
9577
 
9537
9578
  // $FlowFixMe
9538
9579
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9539
9580
  return callSession.sipCallId;
9540
9581
  }).catch(e => {
9541
- logger$5.error(e);
9582
+ logger$7.error(e);
9542
9583
  this.endCurrentCall(callSession);
9543
9584
  throw e;
9544
9585
  });
9545
9586
  }
9546
9587
 
9547
- logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9588
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9548
9589
 
9549
9590
  return Promise.resolve(null);
9550
9591
  }
@@ -9554,7 +9595,7 @@ class WebRTCPhone extends Emitter {
9554
9595
  }
9555
9596
 
9556
9597
  async reject(callSession ) {
9557
- logger$5.info('reject WebRTC called', { id: callSession.getId() });
9598
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
9558
9599
 
9559
9600
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9560
9601
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9566,14 +9607,14 @@ class WebRTCPhone extends Emitter {
9566
9607
 
9567
9608
  const sipSession = this.findSipSession(callSession);
9568
9609
  if (sipSession) {
9569
- logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9610
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
9570
9611
 
9571
9612
  this.client.hangup(sipSession);
9572
9613
  }
9573
9614
  }
9574
9615
 
9575
9616
  async ignore(callSession ) {
9576
- logger$5.info('WebRTC ignore', { id: callSession.getId() });
9617
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
9577
9618
 
9578
9619
  // kill the ring
9579
9620
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9585,14 +9626,14 @@ class WebRTCPhone extends Emitter {
9585
9626
  const sipSession = this.findSipSession(callSession);
9586
9627
 
9587
9628
  if (sipSession) {
9588
- logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9629
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
9589
9630
 
9590
9631
  return this.client.atxfer(sipSession);
9591
9632
  }
9592
9633
  }
9593
9634
 
9594
9635
  hold(callSession , withEvent = true, isConference = false) {
9595
- logger$5.info('WebRTC hold', { id: callSession.getId() });
9636
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
9596
9637
 
9597
9638
  const sipSession = this.findSipSession(callSession);
9598
9639
 
@@ -9607,18 +9648,18 @@ class WebRTCPhone extends Emitter {
9607
9648
  }
9608
9649
 
9609
9650
  resume(callSession , isConference = false, withEvent = true) {
9610
- logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9651
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9611
9652
 
9612
9653
  const sipSession = this.findSipSession(callSession);
9613
9654
  if (!sipSession) {
9614
9655
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9615
9656
  }
9616
9657
 
9617
- logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9658
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
9618
9659
 
9619
9660
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9620
9661
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9621
- logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9662
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9622
9663
  this.holdSipSession(this.currentSipSession, callSession);
9623
9664
  }
9624
9665
 
@@ -9643,7 +9684,7 @@ class WebRTCPhone extends Emitter {
9643
9684
  const sessionId = this.getSipSessionId(sipSession);
9644
9685
  const hasVideo = this.client.hasLocalVideo(sessionId);
9645
9686
 
9646
- logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9687
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9647
9688
 
9648
9689
  // Stop screenshre if needed
9649
9690
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9674,7 +9715,7 @@ class WebRTCPhone extends Emitter {
9674
9715
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9675
9716
  }
9676
9717
  const sessionId = this.getSipSessionId(sipSession);
9677
- logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
9718
+ logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9678
9719
 
9679
9720
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9680
9721
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9718,14 +9759,14 @@ class WebRTCPhone extends Emitter {
9718
9759
  }
9719
9760
 
9720
9761
  mute(callSession , withEvent = true) {
9721
- logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9762
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9722
9763
 
9723
9764
  const sipSession = this.findSipSession(callSession);
9724
9765
  if (!sipSession) {
9725
9766
  return;
9726
9767
  }
9727
9768
 
9728
- logger$5.info('WebRTC muting', { sipId: sipSession.id });
9769
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
9729
9770
  this.client.mute(sipSession);
9730
9771
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9731
9772
 
@@ -9739,14 +9780,14 @@ class WebRTCPhone extends Emitter {
9739
9780
  }
9740
9781
 
9741
9782
  unmute(callSession , withEvent = true) {
9742
- logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9783
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9743
9784
 
9744
9785
  const sipSession = this.findSipSession(callSession);
9745
9786
  if (!sipSession) {
9746
9787
  return;
9747
9788
  }
9748
9789
 
9749
- logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
9790
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9750
9791
  this.client.unmute(sipSession);
9751
9792
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9752
9793
 
@@ -9773,7 +9814,7 @@ class WebRTCPhone extends Emitter {
9773
9814
  if (!sipSession) {
9774
9815
  return;
9775
9816
  }
9776
- logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
9817
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9777
9818
 
9778
9819
  this.client.toggleCameraOn(sipSession);
9779
9820
 
@@ -9785,7 +9826,7 @@ class WebRTCPhone extends Emitter {
9785
9826
  if (!sipSession) {
9786
9827
  return;
9787
9828
  }
9788
- logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
9829
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9789
9830
 
9790
9831
  this.client.toggleCameraOff(sipSession);
9791
9832
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9797,7 +9838,7 @@ class WebRTCPhone extends Emitter {
9797
9838
  return;
9798
9839
  }
9799
9840
 
9800
- logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
9841
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9801
9842
  this.client.sendDTMF(sipSession, tone);
9802
9843
  }
9803
9844
 
@@ -9805,7 +9846,7 @@ class WebRTCPhone extends Emitter {
9805
9846
  // @TODO: line is not used here
9806
9847
  async makeCall(number , line , cameraEnabled ,
9807
9848
  audioOnly = false, conference = false) {
9808
- logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9849
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
9809
9850
  if (!number) {
9810
9851
  return Promise.resolve(null);
9811
9852
  }
@@ -9815,7 +9856,7 @@ class WebRTCPhone extends Emitter {
9815
9856
  }
9816
9857
  if (this.currentSipSession) {
9817
9858
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9818
- logger$5.warn('Unable to hold current session when making another call', e);
9859
+ logger$7.warn('Unable to hold current session when making another call', e);
9819
9860
  });
9820
9861
  }
9821
9862
 
@@ -9825,10 +9866,11 @@ class WebRTCPhone extends Emitter {
9825
9866
  this._bindEvents(sipSession);
9826
9867
  } catch (error) {
9827
9868
  console.warn(error);
9828
- logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9869
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9829
9870
  return Promise.resolve(null);
9830
9871
  }
9831
9872
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9873
+ callSession.creationTime = new Date();
9832
9874
 
9833
9875
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9834
9876
 
@@ -9853,7 +9895,7 @@ class WebRTCPhone extends Emitter {
9853
9895
  return;
9854
9896
  }
9855
9897
 
9856
- logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
9898
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9857
9899
 
9858
9900
  this.client.transfer(sipSession, target);
9859
9901
  }
@@ -9862,7 +9904,7 @@ class WebRTCPhone extends Emitter {
9862
9904
  const sipSession = this.client.getSipSession(source.sipCallId);
9863
9905
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9864
9906
 
9865
- logger$5.info('WebRTC indirect transfer', {
9907
+ logger$7.info('WebRTC indirect transfer', {
9866
9908
  sipId: sipSession ? sipSession.id : null,
9867
9909
  target: sipSessionTarget ? sipSessionTarget.id : null,
9868
9910
  });
@@ -9901,7 +9943,7 @@ class WebRTCPhone extends Emitter {
9901
9943
  return false;
9902
9944
  }
9903
9945
 
9904
- logger$5.info('WebRTC hangup', { sipId: sipSession.id });
9946
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9905
9947
 
9906
9948
  const sipSessionId = this.getSipSessionId(sipSession);
9907
9949
 
@@ -9947,7 +9989,7 @@ class WebRTCPhone extends Emitter {
9947
9989
  endCurrentCall(callSession ) {
9948
9990
  const isCurrent = this.isCurrentCallSipSession(callSession);
9949
9991
 
9950
- logger$5.info('Ending current call', {
9992
+ logger$7.info('Ending current call', {
9951
9993
  id: callSession ? callSession.getId() : null,
9952
9994
  isCurrent,
9953
9995
  });
@@ -9971,7 +10013,7 @@ class WebRTCPhone extends Emitter {
9971
10013
  }
9972
10014
 
9973
10015
  async close() {
9974
- logger$5.info('WebRTC close');
10016
+ logger$7.info('WebRTC close');
9975
10017
 
9976
10018
  try {
9977
10019
  await Promise.race([
@@ -9979,7 +10021,7 @@ class WebRTCPhone extends Emitter {
9979
10021
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9980
10022
  ]);
9981
10023
  } catch (e) {
9982
- logger$5.error('WebRTC close, unregister error', e);
10024
+ logger$7.error('WebRTC close, unregister error', e);
9983
10025
  }
9984
10026
 
9985
10027
  this.client.close();
@@ -9997,12 +10039,12 @@ class WebRTCPhone extends Emitter {
9997
10039
  }
9998
10040
 
9999
10041
  enableRinging() {
10000
- logger$5.info('WebRTC enable ringing');
10042
+ logger$7.info('WebRTC enable ringing');
10001
10043
  this.ringingEnabled = true;
10002
10044
  }
10003
10045
 
10004
10046
  disableRinging() {
10005
- logger$5.info('WebRTC disable ringing');
10047
+ logger$7.info('WebRTC disable ringing');
10006
10048
  this.ringingEnabled = false;
10007
10049
  }
10008
10050
 
@@ -10024,8 +10066,12 @@ class WebRTCPhone extends Emitter {
10024
10066
  }
10025
10067
 
10026
10068
  const sessionId = this.incomingSessions[0];
10069
+ const sipSession = this.client.getSipSession(sessionId);
10070
+ if (!sipSession) {
10071
+ return null;
10072
+ }
10027
10073
 
10028
- return this._createCallSession(this.client.getSipSession(sessionId));
10074
+ return this._createCallSession(sipSession);
10029
10075
  }
10030
10076
 
10031
10077
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10042,7 +10088,7 @@ class WebRTCPhone extends Emitter {
10042
10088
 
10043
10089
  // Deprecated
10044
10090
  getLocalMediaStream(callSession ) {
10045
- logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10091
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10046
10092
  return this.getLocalStream(callSession);
10047
10093
  }
10048
10094
 
@@ -10084,7 +10130,7 @@ class WebRTCPhone extends Emitter {
10084
10130
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10085
10131
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10086
10132
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10087
- logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10133
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10088
10134
 
10089
10135
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10090
10136
  this.incomingSessions.push(callSession.getId());
@@ -10103,11 +10149,12 @@ class WebRTCPhone extends Emitter {
10103
10149
  callSession);
10104
10150
  }
10105
10151
 
10152
+ callSession.creationTime = new Date();
10106
10153
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10107
10154
  });
10108
10155
 
10109
10156
  this.client.on(this.client.ON_REINVITE, (...args) => {
10110
- logger$5.info('WebRTC on reinvite', {
10157
+ logger$7.info('WebRTC on reinvite', {
10111
10158
  sessionId: args[0].id,
10112
10159
  inviteId: args[1].id,
10113
10160
  updatedCalleeName: args[2],
@@ -10127,7 +10174,7 @@ class WebRTCPhone extends Emitter {
10127
10174
  });
10128
10175
 
10129
10176
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10130
- logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10177
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10131
10178
 
10132
10179
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10133
10180
 
@@ -10138,22 +10185,29 @@ class WebRTCPhone extends Emitter {
10138
10185
  this.client.on('ended', () => {});
10139
10186
 
10140
10187
  this.client.on(this.client.ON_ERROR, e => {
10141
- logger$5.error('WebRTC error', e);
10188
+ logger$7.error('WebRTC error', e);
10142
10189
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10143
10190
  });
10144
10191
 
10192
+ this.client.on(this.client.REJECTED, session => {
10193
+ logger$7.info('WebRTC call rejected', session.id);
10194
+ const callSession = this._createCallSession(session);
10195
+ callSession.endTime = new Date();
10196
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10197
+ });
10198
+
10145
10199
  this.client.on(this.client.UNREGISTERED, () => {
10146
- logger$5.info('WebRTC unregistered');
10200
+ logger$7.info('WebRTC unregistered');
10147
10201
  this.eventEmitter.emit(ON_UNREGISTERED);
10148
10202
  });
10149
10203
 
10150
10204
  this.client.on(this.client.ON_DISCONNECTED, () => {
10151
- logger$5.info('WebRTC disconnected');
10152
- this.eventEmitter.emit(ON_DISCONNECTED$1);
10205
+ logger$7.info('WebRTC disconnected');
10206
+ this.eventEmitter.emit(ON_DISCONNECTED);
10153
10207
  });
10154
10208
 
10155
10209
  this.client.on(this.client.REGISTERED, () => {
10156
- logger$5.info('WebRTC registered', {
10210
+ logger$7.info('WebRTC registered', {
10157
10211
  shouldSendReinvite: this.shouldSendReinvite,
10158
10212
  state: this.currentSipSession ? this.currentSipSession.state : null,
10159
10213
  currentSipSession: !!this.currentSipSession,
@@ -10174,19 +10228,19 @@ class WebRTCPhone extends Emitter {
10174
10228
  // Send reinvite with iceRestart
10175
10229
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10176
10230
  } catch (e) {
10177
- logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10231
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10178
10232
  }
10179
10233
  }
10180
10234
  });
10181
10235
 
10182
10236
  this.client.on(this.client.CONNECTED, () => {
10183
- logger$5.info('WebRTC client connected');
10237
+ logger$7.info('WebRTC client connected');
10184
10238
 
10185
10239
  this.stopHeartbeat();
10186
10240
  });
10187
10241
 
10188
10242
  this.client.on(this.client.DISCONNECTED, () => {
10189
- logger$5.info('WebRTC client disconnected');
10243
+ logger$7.info('WebRTC client disconnected');
10190
10244
 
10191
10245
  this.eventEmitter.emit(ON_UNREGISTERED);
10192
10246
 
@@ -10200,7 +10254,7 @@ class WebRTCPhone extends Emitter {
10200
10254
  });
10201
10255
 
10202
10256
  this.client.on(this.client.ON_TRACK, (session, event) => {
10203
- this.eventEmitter.emit(ON_TRACK$1, session, event);
10257
+ this.eventEmitter.emit(ON_TRACK, session, event);
10204
10258
  });
10205
10259
 
10206
10260
  this.client.on('onVideoInputChange', stream => {
@@ -10215,7 +10269,7 @@ class WebRTCPhone extends Emitter {
10215
10269
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10216
10270
  const callSession = this.getCallSession(this.getSipSessionId(session));
10217
10271
 
10218
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10272
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10219
10273
  });
10220
10274
 
10221
10275
  // Used when upgrading directly in screenshare mode
@@ -10224,7 +10278,7 @@ class WebRTCPhone extends Emitter {
10224
10278
  const localStream = this.client.getLocalStream(sipSessionId);
10225
10279
  const callSession = this.callSessions[sipSessionId];
10226
10280
 
10227
- logger$5.info('Updrading directly in screensharing mode', {
10281
+ logger$7.info('Updrading directly in screensharing mode', {
10228
10282
  sipSessionId,
10229
10283
  tracks: localStream ? localStream.getTracks() : null,
10230
10284
  });
@@ -10354,6 +10408,7 @@ class WebRTCPhone extends Emitter {
10354
10408
  const number = identity ? identity.uri._normal.user : null;
10355
10409
  const { state } = sipSession || {};
10356
10410
  const sessionId = this.getSipSessionId(sipSession);
10411
+ fromSession = fromSession || this.callSessions[sessionId];
10357
10412
 
10358
10413
  const callSession = new CallSession({
10359
10414
  callId: fromSession && fromSession.callId,
@@ -10361,6 +10416,8 @@ class WebRTCPhone extends Emitter {
10361
10416
  sipStatus: state,
10362
10417
  displayName: identity ? identity.displayName || number : number,
10363
10418
  startTime: fromSession ? fromSession.startTime : new Date(),
10419
+ creationTime: fromSession ? fromSession.creationTime : null,
10420
+ endTime: fromSession ? fromSession.endTime : null,
10364
10421
  answered: state === sessionState.SessionState.Established,
10365
10422
  paused: this.client.isCallHeld(sipSession),
10366
10423
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10371,6 +10428,7 @@ class WebRTCPhone extends Emitter {
10371
10428
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10372
10429
  recording: fromSession ? fromSession.isRecording() : false,
10373
10430
  recordingPaused: false, // @TODO
10431
+ sipSession,
10374
10432
  ...extra,
10375
10433
  });
10376
10434
 
@@ -10399,11 +10457,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10399
10457
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10400
10458
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10401
10459
  ON_CALL_FAILED: ON_CALL_FAILED,
10460
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10402
10461
  ON_CALL_ENDED: ON_CALL_ENDED,
10403
10462
  ON_CALL_ENDING: ON_CALL_ENDING,
10404
10463
  ON_MESSAGE: ON_MESSAGE,
10405
- ON_REINVITE: ON_REINVITE$1,
10406
- ON_TRACK: ON_TRACK$1,
10464
+ ON_REINVITE: ON_REINVITE,
10465
+ ON_TRACK: ON_TRACK,
10407
10466
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10408
10467
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10409
10468
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10418,16 +10477,24 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10418
10477
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10419
10478
  ON_CALL_ERROR: ON_CALL_ERROR,
10420
10479
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10421
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10480
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10422
10481
  ON_CHAT: ON_CHAT,
10423
10482
  ON_SIGNAL: ON_SIGNAL,
10424
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10483
+ ON_DISCONNECTED: ON_DISCONNECTED,
10425
10484
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10426
10485
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10427
- events: events$1,
10486
+ events: events,
10428
10487
  'default': WebRTCPhone
10429
10488
  });
10430
10489
 
10490
+ /* */
10491
+ class SFUNotAvailableError extends Error {
10492
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10493
+ super(message);
10494
+ this.name = 'SFUNotAvailableError';
10495
+ }
10496
+ }
10497
+
10431
10498
  //
10432
10499
 
10433
10500
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10812,13 +10879,13 @@ class Phone extends Emitter {
10812
10879
 
10813
10880
  checkSfu() {
10814
10881
  if (!this.hasSfu()) {
10815
- throw new Error('Sorry your user is not configured to support video conference');
10882
+ throw new SFUNotAvailableError();
10816
10883
  }
10817
10884
  }
10818
10885
 
10819
10886
  _transferEvents() {
10820
10887
  this.unbind();
10821
- [...events, ...transportEvents].forEach(event => {
10888
+ [...events$1, ...transportEvents].forEach(event => {
10822
10889
  this.client.on(event, (...args) =>
10823
10890
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10824
10891
  });
@@ -10840,7 +10907,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10840
10907
 
10841
10908
  //
10842
10909
 
10843
- const SOCKET_EVENTS = {
10910
+ const SOCKET_EVENTS$1 = {
10844
10911
  ON_OPEN: 'onopen',
10845
10912
  ON_MESSAGE: 'onmessage',
10846
10913
  ON_ERROR: 'onerror',
@@ -10936,7 +11003,7 @@ const BLACKLIST_EVENTS = [
10936
11003
  ];
10937
11004
 
10938
11005
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10939
- const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
11006
+ const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10940
11007
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10941
11008
 
10942
11009
  class WebSocketClient extends Emitter {
@@ -10985,24 +11052,24 @@ class WebSocketClient extends Emitter {
10985
11052
  }
10986
11053
 
10987
11054
  connect() {
10988
- logger$7.info('connect method started', { host: this.host, token: this.token });
11055
+ logger$5.info('connect method started', { host: this.host, token: this.token });
10989
11056
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
10990
11057
  if (this.options.binaryType) {
10991
11058
  this.socket.binaryType = this.options.binaryType;
10992
11059
  }
10993
11060
 
10994
11061
  this.socket.onopen = () => {
10995
- logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
10996
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
11062
+ logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
11063
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10997
11064
  };
10998
11065
 
10999
11066
  this.socket.onerror = event => {
11000
- logger$7.error('on Wazo WS error', event.target);
11001
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
11067
+ logger$5.error('on Wazo WS error', event.target);
11068
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
11002
11069
  };
11003
11070
 
11004
11071
  this.socket.onmessage = (event ) => {
11005
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
11072
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
11006
11073
 
11007
11074
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
11008
11075
  let { name } = message;
@@ -11027,7 +11094,7 @@ class WebSocketClient extends Emitter {
11027
11094
 
11028
11095
  this.socket.onclose = event => {
11029
11096
  // Can't be converted to JSON (circular structure)
11030
- logger$7.info('on Wazo WS close', {
11097
+ logger$5.info('on Wazo WS close', {
11031
11098
  reason: event.reason,
11032
11099
  code: event.code,
11033
11100
  readyState: event.target.readyState,
@@ -11035,22 +11102,22 @@ class WebSocketClient extends Emitter {
11035
11102
  token: this.token,
11036
11103
  });
11037
11104
  this.initialized = false;
11038
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
11105
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
11039
11106
 
11040
11107
  switch (event.code) {
11041
11108
  case 4002:
11042
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
11109
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
11043
11110
  break;
11044
11111
  }
11045
11112
  };
11046
11113
 
11047
11114
  this.socket.onerror = event => {
11048
- logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11115
+ logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11049
11116
  };
11050
11117
  }
11051
11118
 
11052
11119
  close(force = false) {
11053
- logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11120
+ logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11054
11121
 
11055
11122
  if (!this.socket) {
11056
11123
  return;
@@ -11068,7 +11135,7 @@ class WebSocketClient extends Emitter {
11068
11135
 
11069
11136
  updateToken(token ) {
11070
11137
  this.token = token;
11071
- logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11138
+ logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11072
11139
 
11073
11140
  if (this.socket) {
11074
11141
  // If still connected, send the token to the WS
@@ -11086,7 +11153,7 @@ class WebSocketClient extends Emitter {
11086
11153
  }
11087
11154
 
11088
11155
  startHeartbeat() {
11089
- logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11156
+ logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11090
11157
 
11091
11158
  if (!this.socket) {
11092
11159
  this.heartbeat.stop();
@@ -11100,7 +11167,7 @@ class WebSocketClient extends Emitter {
11100
11167
  }
11101
11168
 
11102
11169
  stopHeartbeat() {
11103
- logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11170
+ logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11104
11171
 
11105
11172
  this.heartbeat.stop();
11106
11173
  }
@@ -11130,7 +11197,7 @@ class WebSocketClient extends Emitter {
11130
11197
  }
11131
11198
 
11132
11199
  reconnect(reason ) {
11133
- logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11200
+ logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11134
11201
  if (!this.socket) {
11135
11202
  return;
11136
11203
  }
@@ -11155,7 +11222,7 @@ class WebSocketClient extends Emitter {
11155
11222
  break;
11156
11223
  case 'start':
11157
11224
  this.initialized = true;
11158
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
11225
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
11159
11226
  break;
11160
11227
  default:
11161
11228
  this.eventEmitter.emit('message', message);
@@ -11186,7 +11253,7 @@ class WebSocketClient extends Emitter {
11186
11253
  this.close();
11187
11254
  }
11188
11255
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11189
- logger$7.log('Wazo WS url computed to reconnect', { url });
11256
+ logger$5.log('Wazo WS url computed to reconnect', { url });
11190
11257
 
11191
11258
  return url;
11192
11259
  }
@@ -11194,15 +11261,15 @@ class WebSocketClient extends Emitter {
11194
11261
  _onHeartbeat(message ) {
11195
11262
  if (message.payload === 'pong') {
11196
11263
  this.heartbeat.onHeartbeat();
11197
- logger$7.log('on heartbeat received from Wazo WS');
11264
+ logger$5.log('on heartbeat received from Wazo WS');
11198
11265
  }
11199
11266
  }
11200
11267
 
11201
11268
  async _onHeartbeatTimeout() {
11202
- logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
11269
+ logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
11203
11270
 
11204
11271
  this.close();
11205
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
11272
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
11206
11273
 
11207
11274
  if (this.onHeartBeatTimeout) {
11208
11275
  this.onHeartBeatTimeout();
@@ -11282,7 +11349,7 @@ WebSocketClient.eventLists = [
11282
11349
 
11283
11350
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11284
11351
  __proto__: null,
11285
- SOCKET_EVENTS: SOCKET_EVENTS,
11352
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
11286
11353
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11287
11354
  FAVORITE_ADDED: FAVORITE_ADDED,
11288
11355
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11355,10 +11422,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11355
11422
 
11356
11423
  //
11357
11424
 
11358
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11359
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11425
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11426
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11360
11427
 
11361
- const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
11428
+ const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
11362
11429
 
11363
11430
  class Websocket extends Emitter {
11364
11431
 
@@ -11372,9 +11439,9 @@ class Websocket extends Emitter {
11372
11439
  // $FlowFixMe
11373
11440
  this[key] = OTHER_EVENTS[key];
11374
11441
  });
11375
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
11442
+ Object.keys(SOCKET_EVENTS).forEach(key => {
11376
11443
  // $FlowFixMe
11377
- this[key] = SOCKET_EVENTS$1[key];
11444
+ this[key] = SOCKET_EVENTS[key];
11378
11445
  });
11379
11446
  this.eventLists = WebSocketClient.eventLists;
11380
11447
 
@@ -11382,7 +11449,7 @@ class Websocket extends Emitter {
11382
11449
  }
11383
11450
 
11384
11451
  open(host , session ) {
11385
- logger$8.info('open simple WebSocket', { host, token: session.token });
11452
+ logger$4.info('open simple WebSocket', { host, token: session.token });
11386
11453
  this.ws = new WebSocketClient(
11387
11454
  {
11388
11455
  host,
@@ -11410,7 +11477,7 @@ class Websocket extends Emitter {
11410
11477
  }
11411
11478
 
11412
11479
  updateToken(token ) {
11413
- logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
11480
+ logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
11414
11481
 
11415
11482
  if (!this.ws) {
11416
11483
  return;
@@ -11438,12 +11505,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
11438
11505
 
11439
11506
  //
11440
11507
 
11441
- const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
11508
+ const logger$3 = IssueReporter$1.loggerFor('sdk-sip-room');
11442
11509
 
11443
- class SipRoom extends Room$1 {
11510
+ class SipRoom extends Room {
11444
11511
 
11445
11512
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
11446
- logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
11513
+ logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11447
11514
 
11448
11515
  if (!room) {
11449
11516
  await Wazo.Phone.connect();
@@ -11459,7 +11526,7 @@ class SipRoom extends Room$1 {
11459
11526
  room.setCallId(room.callSession.call.id);
11460
11527
  }
11461
11528
 
11462
- logger$9.info('connected to room', {
11529
+ logger$3.info('connected to room', {
11463
11530
  extension: room.extension,
11464
11531
  });
11465
11532
 
@@ -11467,7 +11534,7 @@ class SipRoom extends Room$1 {
11467
11534
  }
11468
11535
 
11469
11536
  mute() {
11470
- logger$9.info('mute sip room');
11537
+ logger$3.info('mute sip room');
11471
11538
 
11472
11539
  Wazo.Phone.mute(this.callSession, false);
11473
11540
 
@@ -11475,7 +11542,7 @@ class SipRoom extends Room$1 {
11475
11542
  }
11476
11543
 
11477
11544
  unmute() {
11478
- logger$9.info('unmute sip room');
11545
+ logger$3.info('unmute sip room');
11479
11546
 
11480
11547
  Wazo.Phone.unmute(this.callSession, false);
11481
11548
 
@@ -11577,7 +11644,7 @@ class SipRoom extends Room$1 {
11577
11644
 
11578
11645
  //
11579
11646
 
11580
- const logger$a = IssueReporter$1.loggerFor('room');
11647
+ const logger$2 = IssueReporter$1.loggerFor('room');
11581
11648
 
11582
11649
  class Participant extends Emitter {
11583
11650
 
@@ -11699,7 +11766,7 @@ class Participant extends Emitter {
11699
11766
  }
11700
11767
 
11701
11768
  onTalking(isTalking ) {
11702
- logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11769
+ logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11703
11770
  this.isTalking = isTalking;
11704
11771
  // you may notice we're not broadcasting: since all participants are getting this info
11705
11772
  // directly from asterisk, there's no need to do so
@@ -11802,7 +11869,7 @@ class Participant extends Emitter {
11802
11869
  }
11803
11870
 
11804
11871
  updateStatus(status , broadcast = true) {
11805
- logger$a.info('updating participant status', { name: this.name, status });
11872
+ logger$2.info('updating participant status', { name: this.name, status });
11806
11873
 
11807
11874
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11808
11875
  if (status.audioMuted) {
@@ -11850,7 +11917,7 @@ class Participant extends Emitter {
11850
11917
 
11851
11918
  broadcastStatus(inboundStatus = null) {
11852
11919
  const status = inboundStatus || this.getStatus();
11853
- logger$a.info('broadcasting participant status', { callId: this.callId, status });
11920
+ logger$2.info('broadcasting participant status', { callId: this.callId, status });
11854
11921
 
11855
11922
  this.room.sendSignal({
11856
11923
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -12054,7 +12121,7 @@ class NotificationOptions {
12054
12121
 
12055
12122
 
12056
12123
  // Represents a conference room, like `9000`.
12057
- class Room {
12124
+ class Room$1 {
12058
12125
 
12059
12126
 
12060
12127
 
@@ -12075,7 +12142,7 @@ class Room {
12075
12142
  }
12076
12143
 
12077
12144
  connect(callSession ) {
12078
- return new Room({ ...this, connectedCallSession: callSession });
12145
+ return new Room$1({ ...this, connectedCallSession: callSession });
12079
12146
  }
12080
12147
 
12081
12148
  has(callSession ) {
@@ -12084,7 +12151,7 @@ class Room {
12084
12151
 
12085
12152
  addParticipant(uuid , extension , talking = null) {
12086
12153
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12087
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12154
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12088
12155
  }
12089
12156
 
12090
12157
  return this;
@@ -12103,7 +12170,7 @@ class Room {
12103
12170
  updatedParticipants.push(participant);
12104
12171
  }
12105
12172
 
12106
- return new Room({ ...this, participants: updatedParticipants });
12173
+ return new Room$1({ ...this, participants: updatedParticipants });
12107
12174
  }
12108
12175
 
12109
12176
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12119,7 +12186,7 @@ class Room {
12119
12186
  updatedParticipants.push(participant);
12120
12187
  }
12121
12188
 
12122
- return new Room({ ...this, participants: updatedParticipants });
12189
+ return new Room$1({ ...this, participants: updatedParticipants });
12123
12190
  }
12124
12191
 
12125
12192
  hasCallWithId(id ) {
@@ -12127,18 +12194,18 @@ class Room {
12127
12194
  }
12128
12195
 
12129
12196
  disconnect() {
12130
- return new Room({ ...this, connectedCallSession: null });
12197
+ return new Room$1({ ...this, connectedCallSession: null });
12131
12198
  }
12132
12199
 
12133
12200
  removeParticipantWithUUID(uuid ) {
12134
- return new Room({
12201
+ return new Room$1({
12135
12202
  ...this,
12136
12203
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12137
12204
  });
12138
12205
  }
12139
12206
 
12140
12207
  removeParticipantWithExtension(extension ) {
12141
- return new Room({
12208
+ return new Room$1({
12142
12209
  ...this,
12143
12210
  participants: this.participants.filter(participant => participant.extension !== extension),
12144
12211
  });
@@ -12149,7 +12216,7 @@ class Room {
12149
12216
  }
12150
12217
 
12151
12218
  static newFrom(room ) {
12152
- return newFrom(room, Room);
12219
+ return newFrom(room, Room$1);
12153
12220
  }
12154
12221
  }
12155
12222
 
@@ -12456,11 +12523,11 @@ var wazoWebsocket = {
12456
12523
  resolve();
12457
12524
  };
12458
12525
 
12459
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
12526
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
12460
12527
  handleError(`Connection error : ${error}`);
12461
12528
  });
12462
12529
 
12463
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
12530
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
12464
12531
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12465
12532
  client.setOnHeartbeatTimeout(() => {
12466
12533
  handleError('No response to heartbeat');
@@ -12561,7 +12628,7 @@ var webrtc = {
12561
12628
  }),
12562
12629
  };
12563
12630
 
12564
- const parseCandidate$1 = line => {
12631
+ const parseCandidate = line => {
12565
12632
  let parts;
12566
12633
  // Parse both variants.
12567
12634
  if (line.indexOf('a=candidate:') === 0) {
@@ -12652,7 +12719,7 @@ var SymmetricNat = {
12652
12719
  }
12653
12720
 
12654
12721
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
12655
- const cand = parseCandidate$1(e.candidate.candidate);
12722
+ const cand = parseCandidate(e.candidate.candidate);
12656
12723
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
12657
12724
  candidates[cand.relatedPort].push(cand.port);
12658
12725
  } else if (!e.candidate) {
@@ -12720,7 +12787,7 @@ var iceIpv4 = {
12720
12787
  const rawCandidate = e.candidate.candidate;
12721
12788
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
12722
12789
  hasSrflxOrRelay = true;
12723
- const candidate = parseCandidate$1(e.candidate.candidate);
12790
+ const candidate = parseCandidate(e.candidate.candidate);
12724
12791
  ips.push(candidate.ip);
12725
12792
  }
12726
12793
  } else if (!e.candidate) {
@@ -12757,7 +12824,7 @@ var checks = [
12757
12824
 
12758
12825
  //
12759
12826
 
12760
- const logger$b = IssueReporter$1.loggerFor('engine-check');
12827
+ const logger$1 = IssueReporter$1.loggerFor('engine-check');
12761
12828
 
12762
12829
  class Checker {
12763
12830
 
@@ -12775,28 +12842,28 @@ class Checker {
12775
12842
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
12776
12843
  await this._addEngineVersion();
12777
12844
 
12778
- logger$b.info('Engine check starting');
12845
+ logger$1.info('Engine check starting');
12779
12846
 
12780
12847
  for (let i = 0; i < this.checks.length; i++) {
12781
12848
  const { name, check } = this.checks[i];
12782
12849
 
12783
- logger$b.info(`Checking ${name} ...`);
12850
+ logger$1.info(`Checking ${name} ...`);
12784
12851
 
12785
12852
  onCheckBegin(name);
12786
12853
  try {
12787
12854
  // eslint-disable-next-line no-await-in-loop
12788
12855
  const result = await check(this.server, this.session, this.externalAppConfig);
12789
- logger$b.info(`Checking ${name} success.`, { result });
12856
+ logger$1.info(`Checking ${name} success.`, { result });
12790
12857
 
12791
12858
  onCheckResult(name, result);
12792
12859
  } catch (e) {
12793
- logger$b.info(`Checking ${name} failure`, { message: e.message });
12860
+ logger$1.info(`Checking ${name} failure`, { message: e.message });
12794
12861
 
12795
12862
  onCheckResult(name, e);
12796
12863
  }
12797
12864
  }
12798
12865
 
12799
- logger$b.info('Engine check done.');
12866
+ logger$1.info('Engine check done.');
12800
12867
  }
12801
12868
 
12802
12869
  addCheck(check ) {
@@ -12820,7 +12887,7 @@ const Wazo = {
12820
12887
  Auth: Auth$1,
12821
12888
  Phone: Phone$1,
12822
12889
  Websocket: Websocket$1,
12823
- Room: Room$1,
12890
+ Room,
12824
12891
  SipRoom,
12825
12892
  RemoteParticipant,
12826
12893
  LocalParticipant,
@@ -12853,7 +12920,7 @@ const Wazo = {
12853
12920
  Session,
12854
12921
  Voicemail,
12855
12922
  Relocation,
12856
- ConferenceRoom: Room,
12923
+ ConferenceRoom: Room$1,
12857
12924
  CallSession,
12858
12925
  IndirectTransfer,
12859
12926
  SwitchboardCall,
@@ -12878,6 +12945,7 @@ const Wazo = {
12878
12945
  InvalidSubscription,
12879
12946
  InvalidAuthorization,
12880
12947
  CanceledCallError,
12948
+ SFUNotAvailableError,
12881
12949
  };
12882
12950
 
12883
12951
  if (window) {
@@ -12892,9 +12960,9 @@ if (global) {
12892
12960
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12893
12961
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12894
12962
 
12895
- const logger$c = IssueReporter$1.loggerFor('sdk-room');
12963
+ const logger = IssueReporter$1.loggerFor('sdk-room');
12896
12964
 
12897
- class Room$1 extends Emitter {
12965
+ class Room extends Emitter {
12898
12966
 
12899
12967
 
12900
12968
 
@@ -12952,7 +13020,7 @@ class Room$1 extends Emitter {
12952
13020
  extra = {},
12953
13021
  ) {
12954
13022
  super();
12955
- logger$c.info('room initialized', { callId, extension, sourceId, meetingUuid });
13023
+ logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
12956
13024
 
12957
13025
  // Represents the room callSession
12958
13026
  this.callSession = callSession;
@@ -13018,7 +13086,7 @@ class Room$1 extends Emitter {
13018
13086
  * @returns {Promise<Room>}
13019
13087
  */
13020
13088
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
13021
- logger$c.info('connecting to room', { extension, audioOnly, room: !!room });
13089
+ logger.info('connecting to room', { extension, audioOnly, room: !!room });
13022
13090
 
13023
13091
  if (!room) {
13024
13092
  await Wazo.Phone.connect();
@@ -13031,7 +13099,7 @@ class Room$1 extends Emitter {
13031
13099
 
13032
13100
  // Call_created is triggered before call_accepted, so we have to listen for it here.
13033
13101
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
13034
- logger$c.info('room call received via WS', { callId: data.call_id });
13102
+ logger.info('room call received via WS', { callId: data.call_id });
13035
13103
  if (room) {
13036
13104
  room.setCallId(data.call_id);
13037
13105
  }
@@ -13039,7 +13107,7 @@ class Room$1 extends Emitter {
13039
13107
 
13040
13108
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
13041
13109
  // eslint-disable-next-line no-param-reassign
13042
- room = new Room$1(callSession, extension, null, null, extra);
13110
+ room = new Room(callSession, extension, null, null, extra);
13043
13111
 
13044
13112
  // Wait for the call to be accepted
13045
13113
  await new Promise((resolve, reject) => {
@@ -13060,7 +13128,7 @@ class Room$1 extends Emitter {
13060
13128
  // Retrieve conference
13061
13129
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
13062
13130
 
13063
- logger$c.info('connected to room', {
13131
+ logger.info('connected to room', {
13064
13132
  sourceId: conference ? conference.sourceId : null,
13065
13133
  name: conference ? conference.name : null,
13066
13134
  });
@@ -13070,7 +13138,7 @@ class Room$1 extends Emitter {
13070
13138
  room.setName(conference.name);
13071
13139
  }
13072
13140
  } else if (meeting) {
13073
- logger$c.info('Already connected to meeting', {
13141
+ logger.info('Already connected to meeting', {
13074
13142
  uuid: meeting.uuid,
13075
13143
  name: meeting.name,
13076
13144
  });
@@ -13083,13 +13151,13 @@ class Room$1 extends Emitter {
13083
13151
  }
13084
13152
 
13085
13153
  static disconnect() {
13086
- logger$c.info('static disconnection to room');
13154
+ logger.info('static disconnection to room');
13087
13155
 
13088
13156
  Wazo.Phone.disconnect();
13089
13157
  }
13090
13158
 
13091
13159
  async disconnect() {
13092
- logger$c.info('disconnection to room called');
13160
+ logger.info('disconnection to room called');
13093
13161
 
13094
13162
  await Wazo.Phone.hangup(this.callSession);
13095
13163
  this.callSession = null;
@@ -13109,19 +13177,19 @@ class Room$1 extends Emitter {
13109
13177
  }
13110
13178
 
13111
13179
  setSourceId(sourceId ) {
13112
- logger$c.info('set room source id', { sourceId });
13180
+ logger.info('set room source id', { sourceId });
13113
13181
 
13114
13182
  this.sourceId = sourceId;
13115
13183
  }
13116
13184
 
13117
13185
  setMeetingUuid(meetingUuid ) {
13118
- logger$c.info('set meeting uuid', { meetingUuid });
13186
+ logger.info('set meeting uuid', { meetingUuid });
13119
13187
 
13120
13188
  this.meetingUuid = meetingUuid;
13121
13189
  }
13122
13190
 
13123
13191
  setCallId(callId ) {
13124
- logger$c.info('set room call id', { callId });
13192
+ logger.info('set room call id', { callId });
13125
13193
 
13126
13194
  if (callId) {
13127
13195
  this.callId = callId;
@@ -13129,7 +13197,7 @@ class Room$1 extends Emitter {
13129
13197
  }
13130
13198
 
13131
13199
  setName(name ) {
13132
- logger$c.info('set room name', { name });
13200
+ logger.info('set room name', { name });
13133
13201
 
13134
13202
  this.name = name;
13135
13203
  }
@@ -13148,7 +13216,7 @@ class Room$1 extends Emitter {
13148
13216
  }
13149
13217
 
13150
13218
  async startScreenSharing(constraints ) {
13151
- logger$c.info('start room screen sharing', { constraints });
13219
+ logger.info('start room screen sharing', { constraints });
13152
13220
 
13153
13221
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
13154
13222
  if (!screensharingStream) {
@@ -13162,7 +13230,7 @@ class Room$1 extends Emitter {
13162
13230
  }
13163
13231
 
13164
13232
  async stopScreenSharing(restoreLocalStream = true) {
13165
- logger$c.info('stop room screen sharing');
13233
+ logger.info('stop room screen sharing');
13166
13234
 
13167
13235
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
13168
13236
 
@@ -13174,7 +13242,7 @@ class Room$1 extends Emitter {
13174
13242
  }
13175
13243
 
13176
13244
  turnCameraOff() {
13177
- logger$c.info('turn room camera off');
13245
+ logger.info('turn room camera off');
13178
13246
 
13179
13247
  Wazo.Phone.turnCameraOff(this.callSession);
13180
13248
 
@@ -13184,7 +13252,7 @@ class Room$1 extends Emitter {
13184
13252
  }
13185
13253
 
13186
13254
  turnCameraOn() {
13187
- logger$c.info('turn room camera on');
13255
+ logger.info('turn room camera on');
13188
13256
 
13189
13257
  Wazo.Phone.turnCameraOn(this.callSession);
13190
13258
 
@@ -13194,7 +13262,7 @@ class Room$1 extends Emitter {
13194
13262
  }
13195
13263
 
13196
13264
  mute() {
13197
- logger$c.info('mute room');
13265
+ logger.info('mute room');
13198
13266
 
13199
13267
  Wazo.Phone.mute(this.callSession);
13200
13268
 
@@ -13202,7 +13270,7 @@ class Room$1 extends Emitter {
13202
13270
  }
13203
13271
 
13204
13272
  unmute() {
13205
- logger$c.info('unmute room');
13273
+ logger.info('unmute room');
13206
13274
 
13207
13275
  Wazo.Phone.unmute(this.callSession);
13208
13276
 
@@ -13222,7 +13290,7 @@ class Room$1 extends Emitter {
13222
13290
  }
13223
13291
 
13224
13292
  hold() {
13225
- logger$c.info('hold room');
13293
+ logger.info('hold room');
13226
13294
 
13227
13295
  Wazo.Phone.hold(this.callSession, true);
13228
13296
 
@@ -13232,7 +13300,7 @@ class Room$1 extends Emitter {
13232
13300
  }
13233
13301
 
13234
13302
  async resume() {
13235
- logger$c.info('resume room');
13303
+ logger.info('resume room');
13236
13304
 
13237
13305
  const newStream = await Wazo.Phone.resume(this.callSession, true);
13238
13306
 
@@ -13260,13 +13328,13 @@ class Room$1 extends Emitter {
13260
13328
  }
13261
13329
 
13262
13330
  sendDTMF(tone ) {
13263
- logger$c.info('send room DTMF', { tone });
13331
+ logger.info('send room DTMF', { tone });
13264
13332
 
13265
13333
  Wazo.Phone.sendDTMF(tone, this.callSession);
13266
13334
  }
13267
13335
 
13268
13336
  async sendReinvite(newConstraints = null) {
13269
- logger$c.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13337
+ logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13270
13338
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
13271
13339
 
13272
13340
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13325,7 +13393,7 @@ class Room$1 extends Emitter {
13325
13393
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13326
13394
 
13327
13395
  this.on(this.ON_AUDIO_STREAM, stream => {
13328
- logger$c.info('on room audio stream');
13396
+ logger.info('on room audio stream');
13329
13397
 
13330
13398
  this.audioStream = stream;
13331
13399
  if (!this.roomAudioElement) {
@@ -13338,7 +13406,7 @@ class Room$1 extends Emitter {
13338
13406
  });
13339
13407
 
13340
13408
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13341
- logger$c.info('on room video stream', { streamId });
13409
+ logger.info('on room video stream', { streamId });
13342
13410
 
13343
13411
  this._mapMsid(sipSession.body.body);
13344
13412
 
@@ -13353,7 +13421,7 @@ class Room$1 extends Emitter {
13353
13421
  });
13354
13422
 
13355
13423
  this.on(this.ON_REMOVE_STREAM, stream => {
13356
- logger$c.info('on room remove stream');
13424
+ logger.info('on room remove stream');
13357
13425
 
13358
13426
  const participant = this.participants.find(someParticipant =>
13359
13427
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13485,7 +13553,7 @@ class Room$1 extends Emitter {
13485
13553
  const requester = this._getParticipantFromCallId(origin.callId);
13486
13554
  if (requester) {
13487
13555
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13488
- logger$c.info('trigger room requester status', { origin });
13556
+ logger.info('trigger room requester status', { origin });
13489
13557
  requester.triggerUpdate('REQUESTER_UPDATE');
13490
13558
  }
13491
13559
  break;
@@ -13516,24 +13584,24 @@ class Room$1 extends Emitter {
13516
13584
 
13517
13585
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13518
13586
  if (participant.user_uuid === session.uuid) {
13519
- logger$c.info('room current user joined');
13587
+ logger.info('room current user joined');
13520
13588
 
13521
13589
  // Retrieve participants via an API calls
13522
13590
  const conferenceId = this.sourceId || payload.data.conference_id;
13523
13591
  let response;
13524
13592
  try {
13525
13593
  if (this.meetingUuid) {
13526
- logger$c.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13594
+ logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13527
13595
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13528
13596
  } else {
13529
- logger$c.info('fetching conference participants', { conferenceId });
13597
+ logger.info('fetching conference participants', { conferenceId });
13530
13598
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13531
13599
  }
13532
13600
  } catch (e) {
13533
- logger$c.error('room participants fetching, error', e);
13601
+ logger.error('room participants fetching, error', e);
13534
13602
  }
13535
13603
  if (response) {
13536
- logger$c.info('conference participants fetched', { nb: response.items.length });
13604
+ logger.info('conference participants fetched', { nb: response.items.length });
13537
13605
  participants = response.items.map(item => {
13538
13606
  const isMe = item.call_id === this.callId;
13539
13607
 
@@ -13560,7 +13628,7 @@ class Room$1 extends Emitter {
13560
13628
  ? new Wazo.RemoteParticipant(this, participant)
13561
13629
  : null;
13562
13630
 
13563
- logger$c.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13631
+ logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13564
13632
 
13565
13633
  if (remoteParticipant) {
13566
13634
  this.participants.push(remoteParticipant);