@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
@@ -459,11 +459,11 @@ var IssueReporter$1 = new IssueReporter();
459
459
 
460
460
  const methods = ['head', 'get', 'post', 'put', 'delete'];
461
461
 
462
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
462
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
463
463
 
464
464
  // Use a function here to be able to mock it in tests
465
465
  const realFetch = () => {
466
- if (typeof document !== 'undefined') {
466
+ if (typeof document !== 'undefined' && window.fetch) {
467
467
  // Browser
468
468
  return window.fetch;
469
469
  }
@@ -598,7 +598,7 @@ class ApiRequester {
598
598
  };
599
599
 
600
600
  if (this.refreshTokenPromise) {
601
- logger.info('A token is already refreshing, waiting ...', { url });
601
+ logger$c.info('A token is already refreshing, waiting ...', { url });
602
602
  await this.refreshTokenPromise;
603
603
  }
604
604
 
@@ -618,7 +618,7 @@ class ApiRequester {
618
618
  return promise.then(async (err ) => {
619
619
  // Check if the token is still valid
620
620
  if (firstCall && this._checkTokenExpired(response, err)) {
621
- logger.warn('token expired', { error: err.reason });
621
+ logger$c.warn('token expired', { error: err.reason });
622
622
  // Replay the call after refreshing the token
623
623
  return this._replayWithNewToken(err, path, method, body, headers, parse);
624
624
  }
@@ -628,7 +628,7 @@ class ApiRequester {
628
628
  : exceptionClass.fromResponse(err, response.status);
629
629
 
630
630
  if (this.shouldLogErrors) {
631
- logger.error('API error', error);
631
+ logger$c.error('API error', error);
632
632
  }
633
633
 
634
634
  throw error;
@@ -638,7 +638,7 @@ class ApiRequester {
638
638
  return newParse(response, isJson);
639
639
  }).catch(error => {
640
640
  if (this.shouldLogErrors) {
641
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
641
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
642
642
  }
643
643
 
644
644
  throw error;
@@ -666,13 +666,13 @@ class ApiRequester {
666
666
  ) {
667
667
  const isTokenNotFound = this._isTokenNotFound(err);
668
668
  let newPath = path;
669
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
669
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
670
670
 
671
671
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
672
672
 
673
673
  return this.refreshTokenPromise.then(() => {
674
674
  this.refreshTokenPromise = null;
675
- logger.info('token refreshed', { isTokenNotFound });
675
+ logger$c.info('token refreshed', { isTokenNotFound });
676
676
  if (isTokenNotFound) {
677
677
  const pathParts = path.split('/');
678
678
  pathParts.pop();
@@ -1923,7 +1923,7 @@ class Contact {
1923
1923
  this[key] = old[key] || this[key];
1924
1924
  });
1925
1925
 
1926
- if (old.lineState && !this.lineState) {
1926
+ if (old.lineState) {
1927
1927
  this.lineState = old.lineState;
1928
1928
  }
1929
1929
 
@@ -3253,8 +3253,10 @@ var updateFrom = (instance , from ) => {
3253
3253
 
3254
3254
 
3255
3255
 
3256
+
3256
3257
 
3257
3258
 
3259
+
3258
3260
 
3259
3261
 
3260
3262
 
@@ -3271,6 +3273,7 @@ var updateFrom = (instance , from ) => {
3271
3273
 
3272
3274
 
3273
3275
 
3276
+
3274
3277
 
3275
3278
 
3276
3279
  class CallSession {
@@ -3290,8 +3293,12 @@ class CallSession {
3290
3293
 
3291
3294
 
3292
3295
 
3296
+
3297
+
3293
3298
 
3294
3299
 
3300
+
3301
+
3295
3302
 
3296
3303
 
3297
3304
 
@@ -3329,6 +3336,8 @@ class CallSession {
3329
3336
 
3330
3337
 
3331
3338
 
3339
+
3340
+
3332
3341
 
3333
3342
  constructor({
3334
3343
  answered,
@@ -3342,6 +3351,8 @@ class CallSession {
3342
3351
  paused,
3343
3352
  ringing,
3344
3353
  startTime,
3354
+ creationTime,
3355
+ endTime,
3345
3356
  cameraEnabled,
3346
3357
  dialedExtension,
3347
3358
  sipCallId,
@@ -3354,12 +3365,15 @@ class CallSession {
3354
3365
  recording,
3355
3366
  recordingPaused,
3356
3367
  videoRemotelyDowngraded,
3368
+ sipSession,
3357
3369
  } ) {
3358
3370
  this.callId = callId;
3359
3371
  this.sipCallId = sipCallId;
3360
3372
  this.displayName = displayName;
3361
3373
  this.number = number;
3374
+ this.creationTime = creationTime;
3362
3375
  this.startTime = startTime;
3376
+ this.endTime = endTime;
3363
3377
  this.isCaller = isCaller;
3364
3378
  this.answered = answered;
3365
3379
  this.answeredBySystem = answeredBySystem;
@@ -3378,6 +3392,7 @@ class CallSession {
3378
3392
  this.recording = recording || false;
3379
3393
  this.recordingPaused = recordingPaused || false;
3380
3394
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3395
+ this.sipSession = sipSession;
3381
3396
 
3382
3397
  // Useful to compare instead of instanceof with minified code
3383
3398
  this.type = 'CallSession';
@@ -4053,7 +4068,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4053
4068
 
4054
4069
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4055
4070
 
4056
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4071
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4057
4072
 
4058
4073
  class CTIPhone extends Emitter {
4059
4074
 
@@ -4066,7 +4081,7 @@ class CTIPhone extends Emitter {
4066
4081
 
4067
4082
  constructor(session , isMobile = false, callbackAllLines = false) {
4068
4083
  super();
4069
- logger$1.info('CTI Phone created');
4084
+ logger$b.info('CTI Phone created');
4070
4085
  this.session = session;
4071
4086
  this.isMobile = isMobile;
4072
4087
  this.callbackAllLines = callbackAllLines;
@@ -4127,7 +4142,7 @@ class CTIPhone extends Emitter {
4127
4142
  }
4128
4143
 
4129
4144
  async makeCall(number , line ) {
4130
- logger$1.info('make CTI call', { number });
4145
+ logger$b.info('make CTI call', { number });
4131
4146
 
4132
4147
  if (!number) {
4133
4148
  return null;
@@ -4150,7 +4165,7 @@ class CTIPhone extends Emitter {
4150
4165
  if (!callSession) {
4151
4166
  return Promise.resolve(null);
4152
4167
  }
4153
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4168
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4154
4169
 
4155
4170
  if (!this.currentCall) {
4156
4171
  this.currentCall = callSession.call;
@@ -4163,7 +4178,7 @@ class CTIPhone extends Emitter {
4163
4178
  if (!callSession) {
4164
4179
  return;
4165
4180
  }
4166
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4181
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4167
4182
 
4168
4183
  this.currentCall = undefined;
4169
4184
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4173,7 +4188,7 @@ class CTIPhone extends Emitter {
4173
4188
  if (!callSession) {
4174
4189
  return Promise.resolve(false);
4175
4190
  }
4176
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4191
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4177
4192
 
4178
4193
  try {
4179
4194
  await CallApi.cancelCall(callSession);
@@ -4184,7 +4199,7 @@ class CTIPhone extends Emitter {
4184
4199
  this.eventEmitter.emit('onCallEnded', callSession);
4185
4200
  return true;
4186
4201
  } catch (e) {
4187
- logger$1.error('hangup CTI call, error', e);
4202
+ logger$b.error('hangup CTI call, error', e);
4188
4203
 
4189
4204
  this.eventEmitter.emit('onCallFailed', callSession);
4190
4205
  return false;
@@ -4197,7 +4212,7 @@ class CTIPhone extends Emitter {
4197
4212
  if (!callSession) {
4198
4213
  return;
4199
4214
  }
4200
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4215
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4201
4216
 
4202
4217
  await CallApi.cancelCall(callSession);
4203
4218
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4207,7 +4222,7 @@ class CTIPhone extends Emitter {
4207
4222
  if (!callSession) {
4208
4223
  return;
4209
4224
  }
4210
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4225
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4211
4226
 
4212
4227
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4213
4228
  }
@@ -4220,19 +4235,19 @@ class CTIPhone extends Emitter {
4220
4235
  if (!callSession) {
4221
4236
  return;
4222
4237
  }
4223
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4238
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4224
4239
 
4225
4240
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4226
4241
  }
4227
4242
 
4228
4243
  async cancelCTIIndirectTransfer(transferId ) {
4229
- logger$1.info('cancel CTI transfer', { transferId });
4244
+ logger$b.info('cancel CTI transfer', { transferId });
4230
4245
 
4231
4246
  return CallApi.cancelCallTransfer(transferId);
4232
4247
  }
4233
4248
 
4234
4249
  async confirmCTIIndirectTransfer(transferId ) {
4235
- logger$1.info('confirm CTI transfer', { transferId });
4250
+ logger$b.info('confirm CTI transfer', { transferId });
4236
4251
 
4237
4252
  return CallApi.confirmCallTransfer(transferId);
4238
4253
  }
@@ -4241,19 +4256,19 @@ class CTIPhone extends Emitter {
4241
4256
  if (!callSession) {
4242
4257
  return;
4243
4258
  }
4244
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4259
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4245
4260
 
4246
4261
  return CallApi.sendDTMF(callSession.callId, digits);
4247
4262
  }
4248
4263
 
4249
4264
  onConnectionMade() {
4250
- logger$1.info('on CTI connection made');
4265
+ logger$b.info('on CTI connection made');
4251
4266
 
4252
4267
  this.eventEmitter.emit('onCallAccepted');
4253
4268
  }
4254
4269
 
4255
4270
  async close() {
4256
- logger$1.info('CTI close');
4271
+ logger$b.info('CTI close');
4257
4272
 
4258
4273
  return Promise.resolve();
4259
4274
  }
@@ -4262,7 +4277,7 @@ class CTIPhone extends Emitter {
4262
4277
  if (!callSession) {
4263
4278
  return;
4264
4279
  }
4265
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4280
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4266
4281
 
4267
4282
  return CallApi.hold(callSession.callId);
4268
4283
  }
@@ -4271,7 +4286,7 @@ class CTIPhone extends Emitter {
4271
4286
  if (!callSession) {
4272
4287
  return;
4273
4288
  }
4274
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4289
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4275
4290
 
4276
4291
  return CallApi.resume(callSession.callId);
4277
4292
  }
@@ -4280,7 +4295,7 @@ class CTIPhone extends Emitter {
4280
4295
  if (!callSession) {
4281
4296
  return;
4282
4297
  }
4283
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4298
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4284
4299
 
4285
4300
  return CallApi.mute(callSession.callId);
4286
4301
  }
@@ -4289,7 +4304,7 @@ class CTIPhone extends Emitter {
4289
4304
  if (!callSession) {
4290
4305
  return;
4291
4306
  }
4292
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4307
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4293
4308
 
4294
4309
  return CallApi.unmute(callSession.callId);
4295
4310
  }
@@ -5298,7 +5313,7 @@ const AGENTD_VERSION = '1.0';
5298
5313
  const WEBHOOKD_VERSION = '1.0';
5299
5314
  const AMID_VERSION = '1.0';
5300
5315
 
5301
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5316
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5302
5317
 
5303
5318
  class ApiClient {
5304
5319
 
@@ -5350,12 +5365,12 @@ class ApiClient {
5350
5365
  }
5351
5366
 
5352
5367
  async forceRefreshToken() {
5353
- logger$2.info('forcing refresh token, calling callback');
5368
+ logger$a.info('forcing refresh token, calling callback');
5354
5369
  return this.refreshTokenCallback();
5355
5370
  }
5356
5371
 
5357
5372
  async refreshTokenCallback() {
5358
- logger$2.info('refresh token callback called', {
5373
+ logger$a.info('refresh token callback called', {
5359
5374
  refreshToken: this.refreshToken,
5360
5375
  refreshBackend: this.refreshBackend,
5361
5376
  refreshExpiration: this.refreshExpiration,
@@ -5373,7 +5388,7 @@ class ApiClient {
5373
5388
  this.isMobile,
5374
5389
  );
5375
5390
 
5376
- logger$2.info('token refreshed', { token: session.token });
5391
+ logger$a.info('token refreshed', { token: session.token });
5377
5392
 
5378
5393
  if (this.onRefreshToken) {
5379
5394
  this.onRefreshToken(session.token, session);
@@ -5514,7 +5529,7 @@ var getApiClient = (forServer ) => {
5514
5529
  class InvalidSubscription extends Error {}
5515
5530
  class InvalidAuthorization extends Error {}
5516
5531
 
5517
- const logger$3 = IssueReporter$1.loggerFor('simple-auth');
5532
+ const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5518
5533
 
5519
5534
  class Auth {
5520
5535
 
@@ -5549,7 +5564,7 @@ class Auth {
5549
5564
  setApiClientId(this.clientId);
5550
5565
  setRefreshExpiration(this.expiration);
5551
5566
  setOnRefreshToken((token , session ) => {
5552
- logger$3.info('on refresh token done', { token });
5567
+ logger$9.info('on refresh token done', { token });
5553
5568
  setApiToken(token);
5554
5569
  Wazo.Websocket.updateToken(token);
5555
5570
 
@@ -5594,7 +5609,7 @@ class Auth {
5594
5609
  const rawSession = await getApiClient().auth.authenticate(token);
5595
5610
  return this._onAuthenticated(rawSession);
5596
5611
  } catch (e) {
5597
- logger$3.error('on validate token error', e);
5612
+ logger$9.error('on validate token error', e);
5598
5613
  console.warn(e);
5599
5614
  return false;
5600
5615
  }
@@ -5950,7 +5965,7 @@ class AdHocAPIConference {
5950
5965
 
5951
5966
  /* */
5952
5967
 
5953
- const parseCandidate = (candidate ) => {
5968
+ const parseCandidate$1 = (candidate ) => {
5954
5969
  if (!candidate) {
5955
5970
  return null;
5956
5971
  }
@@ -6062,11 +6077,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6062
6077
 
6063
6078
  // $FlowFixMe
6064
6079
  setRemoteSessionDescription(sessionDescription ) {
6065
- const result = super.setRemoteSessionDescription(sessionDescription);
6080
+ try {
6081
+ const result = super.setRemoteSessionDescription(sessionDescription);
6066
6082
 
6067
- this.eventEmitter.emit('setDescription', sessionDescription);
6083
+ this.eventEmitter.emit('setDescription', sessionDescription);
6068
6084
 
6069
- return result;
6085
+ return result;
6086
+ } catch (error) {
6087
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
6088
+ throw error;
6089
+ }
6070
6090
  }
6071
6091
 
6072
6092
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6104,7 +6124,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6104
6124
  this.peerConnectionDelegate.onicecandidate = event => {
6105
6125
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6106
6126
  if (event.candidate) {
6107
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
6127
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6108
6128
  }
6109
6129
  };
6110
6130
 
@@ -6568,7 +6588,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6568
6588
  const SEND_STATS_DELAY = 5000;
6569
6589
 
6570
6590
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6571
- const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6591
+ const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6572
6592
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6573
6593
 
6574
6594
  // events
@@ -6582,14 +6602,14 @@ const TRANSPORT_ERROR = 'transportError';
6582
6602
  const MESSAGE = 'message';
6583
6603
  const ACCEPTED = 'accepted';
6584
6604
  const REJECTED = 'rejected';
6585
- const ON_TRACK = 'onTrack';
6586
- const ON_REINVITE = 'reinvite';
6605
+ const ON_TRACK$1 = 'onTrack';
6606
+ const ON_REINVITE$1 = 'reinvite';
6587
6607
  const ON_ERROR = 'onError';
6588
6608
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6589
- const ON_NETWORK_STATS = 'onNetworkStats';
6590
- const ON_DISCONNECTED = 'onDisconnected';
6609
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6610
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6591
6611
 
6592
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6612
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6593
6613
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6594
6614
  class CanceledCallError extends Error {}
6595
6615
 
@@ -6725,12 +6745,12 @@ class WebRTCClient extends Emitter {
6725
6745
  this.MESSAGE = MESSAGE;
6726
6746
  this.ACCEPTED = ACCEPTED;
6727
6747
  this.REJECTED = REJECTED;
6728
- this.ON_TRACK = ON_TRACK;
6729
- this.ON_REINVITE = ON_REINVITE;
6748
+ this.ON_TRACK = ON_TRACK$1;
6749
+ this.ON_REINVITE = ON_REINVITE$1;
6730
6750
  this.ON_ERROR = ON_ERROR;
6731
6751
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6732
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6733
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6752
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6753
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6734
6754
  }
6735
6755
 
6736
6756
  configureMedia(media ) {
@@ -6747,13 +6767,13 @@ class WebRTCClient extends Emitter {
6747
6767
 
6748
6768
  createUserAgent(configOverrides ) {
6749
6769
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6750
- logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
6770
+ logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6751
6771
 
6752
6772
  webRTCConfiguration.delegate = {
6753
6773
  onConnect: this.onConnect.bind(this),
6754
6774
  onDisconnect: this.onDisconnect.bind(this),
6755
6775
  onInvite: (invitation ) => {
6756
- logger$4.info('sdk webrtc on invite', {
6776
+ logger$8.info('sdk webrtc on invite', {
6757
6777
  method: 'delegate.onInvite',
6758
6778
  id: invitation.id,
6759
6779
  remoteURI: invitation.remoteURI,
@@ -6796,7 +6816,7 @@ class WebRTCClient extends Emitter {
6796
6816
  }
6797
6817
 
6798
6818
  onConnect() {
6799
- logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6819
+ logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6800
6820
  this.eventEmitter.emit(CONNECTED);
6801
6821
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6802
6822
  this.registerer.waitingToggle(false);
@@ -6805,7 +6825,7 @@ class WebRTCClient extends Emitter {
6805
6825
  }
6806
6826
 
6807
6827
  async onDisconnect(error ) {
6808
- logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6828
+ logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6809
6829
  this.connectionPromise = null;
6810
6830
  // The UA will attempt to reconnect automatically when an error occurred
6811
6831
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6830,37 +6850,37 @@ class WebRTCClient extends Emitter {
6830
6850
  };
6831
6851
 
6832
6852
  if (this.skipRegister) {
6833
- logger$4.info('sdk webrtc skip register...', logInfo);
6853
+ logger$8.info('sdk webrtc skip register...', logInfo);
6834
6854
  return Promise.resolve();
6835
6855
  }
6836
6856
 
6837
- logger$4.info('sdk webrtc registering...', logInfo);
6857
+ logger$8.info('sdk webrtc registering...', logInfo);
6838
6858
 
6839
6859
  if (!this.userAgent) {
6840
- logger$4.info('sdk webrtc recreating User Agent');
6860
+ logger$8.info('sdk webrtc recreating User Agent');
6841
6861
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6842
6862
  }
6843
6863
  if (!this.userAgent || this.isRegistered()) {
6844
- logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
6864
+ logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6845
6865
  return Promise.resolve();
6846
6866
  }
6847
6867
 
6848
6868
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6849
- logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
6869
+ logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6850
6870
  return Promise.resolve();
6851
6871
  }
6852
6872
 
6853
6873
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6854
6874
 
6855
6875
  const onRegisterFailed = () => {
6856
- logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6876
+ logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6857
6877
  this.connectionPromise = null;
6858
6878
  if (this.registerer && this.registerer.waiting) {
6859
6879
  this.registerer.waitingToggle(false);
6860
6880
  }
6861
6881
 
6862
6882
  if (tries <= MAX_REGISTER_TRIES) {
6863
- logger$4.info('sdk webrtc registering, retrying...', { tries });
6883
+ logger$8.info('sdk webrtc registering, retrying...', { tries });
6864
6884
  setTimeout(() => this.register(tries + 1), 300);
6865
6885
  }
6866
6886
  };
@@ -6869,18 +6889,18 @@ class WebRTCClient extends Emitter {
6869
6889
  // Avoid race condition with the close method called just before register and setting userAgent to null
6870
6890
  // during the resolution of the primise.
6871
6891
  if (!this.userAgent) {
6872
- logger$4.info('sdk webrtc recreating User Agent after connection');
6892
+ logger$8.info('sdk webrtc recreating User Agent after connection');
6873
6893
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6874
6894
  }
6875
6895
 
6876
- logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6896
+ logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6877
6897
  this.registerer = new Registerer(this.userAgent, registerOptions);
6878
6898
  this.connectionPromise = null;
6879
6899
  this._monkeyPatchRegisterer(this.registerer);
6880
6900
 
6881
6901
  // Bind registerer events
6882
6902
  this.registerer.stateChange.addListener(newState => {
6883
- logger$4.info('sdk webrtc registering, state changed', { newState });
6903
+ logger$8.info('sdk webrtc registering, state changed', { newState });
6884
6904
 
6885
6905
  if (newState === RegistererState.Registered && this.registerer
6886
6906
  && this.registerer.state === RegistererState.Registered) {
@@ -6893,7 +6913,7 @@ class WebRTCClient extends Emitter {
6893
6913
  const options = {
6894
6914
  requestDelegate: {
6895
6915
  onReject: response => {
6896
- logger$4.error('sdk webrtc registering, rejected', { response });
6916
+ logger$8.error('sdk webrtc registering, rejected', { response });
6897
6917
 
6898
6918
  onRegisterFailed();
6899
6919
  },
@@ -6901,13 +6921,13 @@ class WebRTCClient extends Emitter {
6901
6921
  };
6902
6922
 
6903
6923
  return this.registerer.register(options).catch((e) => {
6904
- logger$4.error('sdk webrtc registering, error', e);
6924
+ logger$8.error('sdk webrtc registering, error', e);
6905
6925
 
6906
6926
  this.eventEmitter.emit(REGISTRATION_FAILED);
6907
6927
  return e;
6908
6928
  });
6909
6929
  }).catch(error => {
6910
- logger$4.error('sdk webrtc registering, transport error', error);
6930
+ logger$8.error('sdk webrtc registering, transport error', error);
6911
6931
  onRegisterFailed();
6912
6932
  });
6913
6933
  }
@@ -6936,21 +6956,21 @@ class WebRTCClient extends Emitter {
6936
6956
  }
6937
6957
 
6938
6958
  unregister() {
6939
- logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6959
+ logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6940
6960
  if (!this.registerer) {
6941
6961
  return Promise.resolve();
6942
6962
  }
6943
6963
 
6944
6964
  try {
6945
6965
  return this.registerer.unregister().then(() => {
6946
- logger$4.info('sdk webrtc unregistered');
6966
+ logger$8.info('sdk webrtc unregistered');
6947
6967
  this._cleanupRegister();
6948
6968
  }).catch(e => {
6949
- logger$4.error('sdk webrtc unregistering, promise error', e);
6969
+ logger$8.error('sdk webrtc unregistering, promise error', e);
6950
6970
  this._cleanupRegister();
6951
6971
  });
6952
6972
  } catch (e) {
6953
- logger$4.error('sdk webrtc unregistering, error', e);
6973
+ logger$8.error('sdk webrtc unregistering, error', e);
6954
6974
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6955
6975
  // error when the registerer is in a bad state
6956
6976
  this._cleanupRegister();
@@ -6958,7 +6978,7 @@ class WebRTCClient extends Emitter {
6958
6978
  }
6959
6979
 
6960
6980
  stop() {
6961
- logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6981
+ logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6962
6982
  if (!this.userAgent) {
6963
6983
  return Promise.resolve();
6964
6984
  }
@@ -6966,12 +6986,12 @@ class WebRTCClient extends Emitter {
6966
6986
  return this.userAgent.stop().then(() => {
6967
6987
  return this._cleanupRegister();
6968
6988
  }).catch(e => {
6969
- logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6989
+ logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6970
6990
  });
6971
6991
  }
6972
6992
 
6973
6993
  call(number , enableVideo , audioOnly = false, conference = false) {
6974
- logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6994
+ logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6975
6995
  const inviterOptions = {
6976
6996
  sessionDescriptionHandlerOptionsReInvite: {
6977
6997
  conference,
@@ -7002,7 +7022,7 @@ class WebRTCClient extends Emitter {
7002
7022
  this._onAccepted(session, response.session, true);
7003
7023
  },
7004
7024
  onReject: (response ) => {
7005
- logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7025
+ logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7006
7026
  this._stopSendingStats(session);
7007
7027
  this.stopNetworkMonitoring(session);
7008
7028
 
@@ -7025,11 +7045,11 @@ class WebRTCClient extends Emitter {
7025
7045
  }
7026
7046
 
7027
7047
  answer(session , enableVideo ) {
7028
- logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
7048
+ logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
7029
7049
 
7030
7050
  if (!session || !session.accept) {
7031
7051
  const error = 'No session to answer, or not an invitation';
7032
- logger$4.warn(error);
7052
+ logger$8.warn(error);
7033
7053
  return Promise.reject(new Error(error));
7034
7054
  }
7035
7055
  const options = {
@@ -7039,15 +7059,15 @@ class WebRTCClient extends Emitter {
7039
7059
  return session.accept(options).then(() => {
7040
7060
  if (session.isCanceled) {
7041
7061
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
7042
- logger$4.error(message, { id: session.id });
7062
+ logger$8.error(message, { id: session.id });
7043
7063
  this.onCallEnded(session);
7044
7064
 
7045
7065
  throw new CanceledCallError(message);
7046
7066
  }
7047
- logger$4.info('sdk webrtc answer, accepted.');
7067
+ logger$8.info('sdk webrtc answer, accepted.');
7048
7068
  this._onAccepted(session);
7049
7069
  }).catch(e => {
7050
- logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7070
+ logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7051
7071
 
7052
7072
  throw e;
7053
7073
  });
@@ -7055,7 +7075,7 @@ class WebRTCClient extends Emitter {
7055
7075
 
7056
7076
  hangup(session ) {
7057
7077
  const { state, id } = session;
7058
- logger$4.info('sdk webrtc hangup call', { id, state });
7078
+ logger$8.info('sdk webrtc hangup call', { id, state });
7059
7079
 
7060
7080
  try {
7061
7081
  this._stopSendingStats(session);
@@ -7084,7 +7104,7 @@ class WebRTCClient extends Emitter {
7084
7104
 
7085
7105
  return bye();
7086
7106
  } catch (error) {
7087
- logger$4.warn('sdk webrtc hangup, error', error);
7107
+ logger$8.warn('sdk webrtc hangup, error', error);
7088
7108
  }
7089
7109
 
7090
7110
  return null;
@@ -7102,7 +7122,7 @@ class WebRTCClient extends Emitter {
7102
7122
  // Fetch and emit an event at `interval` with session network stats
7103
7123
  startNetworkMonitoring(session , interval = 1000) {
7104
7124
  const sessionId = this.getSipSessionId(session);
7105
- logger$4.info('starting network inspection', { id: sessionId });
7125
+ logger$8.info('starting network inspection', { id: sessionId });
7106
7126
 
7107
7127
  this.sessionNetworkStats[sessionId] = [];
7108
7128
 
@@ -7112,7 +7132,7 @@ class WebRTCClient extends Emitter {
7112
7132
  stopNetworkMonitoring(session ) {
7113
7133
  const sessionId = this.getSipSessionId(session);
7114
7134
  const exists = sessionId in this.networkMonitoringInterval;
7115
- logger$4.info('stopping network inspection', { id: sessionId, exists });
7135
+ logger$8.info('stopping network inspection', { id: sessionId, exists });
7116
7136
 
7117
7137
  if (exists) {
7118
7138
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -7122,17 +7142,17 @@ class WebRTCClient extends Emitter {
7122
7142
  }
7123
7143
 
7124
7144
  reject(session ) {
7125
- logger$4.info('sdk webrtc reject call', { id: session.id });
7145
+ logger$8.info('sdk webrtc reject call', { id: session.id });
7126
7146
 
7127
7147
  try {
7128
7148
  return session.reject ? session.reject() : session.cancel();
7129
7149
  } catch (e) {
7130
- logger$4.warn('Error when rejecting call', e.message, e.stack);
7150
+ logger$8.warn('Error when rejecting call', e.message, e.stack);
7131
7151
  }
7132
7152
  }
7133
7153
 
7134
7154
  async close() {
7135
- logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7155
+ logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7136
7156
  this._cleanupMedia();
7137
7157
  this.connectionPromise = null;
7138
7158
 
@@ -7163,7 +7183,7 @@ class WebRTCClient extends Emitter {
7163
7183
  // eg: "INVITE not rejectable in state Completed"
7164
7184
  }
7165
7185
  this.userAgent = null;
7166
- logger$4.info('sdk webrtc client closed');
7186
+ logger$8.info('sdk webrtc client closed');
7167
7187
  }
7168
7188
 
7169
7189
  getNumber(session ) {
@@ -7176,13 +7196,13 @@ class WebRTCClient extends Emitter {
7176
7196
  }
7177
7197
 
7178
7198
  mute(session ) {
7179
- logger$4.info('sdk webrtc mute', { id: session.id });
7199
+ logger$8.info('sdk webrtc mute', { id: session.id });
7180
7200
 
7181
7201
  this._toggleAudio(session, true);
7182
7202
  }
7183
7203
 
7184
7204
  unmute(session ) {
7185
- logger$4.info('sdk webrtc unmute', { id: session.id });
7205
+ logger$8.info('sdk webrtc unmute', { id: session.id });
7186
7206
 
7187
7207
  this._toggleAudio(session, false);
7188
7208
  }
@@ -7222,13 +7242,13 @@ class WebRTCClient extends Emitter {
7222
7242
  }
7223
7243
 
7224
7244
  toggleCameraOn(session ) {
7225
- logger$4.info('sdk webrtc toggle camera on', { id: session.id });
7245
+ logger$8.info('sdk webrtc toggle camera on', { id: session.id });
7226
7246
 
7227
7247
  this._toggleVideo(session, false);
7228
7248
  }
7229
7249
 
7230
7250
  toggleCameraOff(session ) {
7231
- logger$4.info('sdk webrtc toggle camera off', { id: session.id });
7251
+ logger$8.info('sdk webrtc toggle camera off', { id: session.id });
7232
7252
 
7233
7253
  this._toggleVideo(session, true);
7234
7254
  }
@@ -7237,7 +7257,7 @@ class WebRTCClient extends Emitter {
7237
7257
  const sessionId = this.getSipSessionId(session);
7238
7258
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
7239
7259
 
7240
- logger$4.info('sdk webrtc hold', {
7260
+ logger$8.info('sdk webrtc hold', {
7241
7261
  sessionId,
7242
7262
  keys: Object.keys(this.heldSessions),
7243
7263
  pendingReinvite: !!session.pendingReinvite,
@@ -7286,7 +7306,7 @@ class WebRTCClient extends Emitter {
7286
7306
  const sessionId = this.getSipSessionId(session);
7287
7307
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7288
7308
 
7289
- logger$4.info('sdk webrtc unhold', {
7309
+ logger$8.info('sdk webrtc unhold', {
7290
7310
  sessionId,
7291
7311
  keys: Object.keys(this.heldSessions),
7292
7312
  pendingReinvite: !!session.pendingReinvite,
@@ -7434,7 +7454,7 @@ class WebRTCClient extends Emitter {
7434
7454
  if (!session.sessionDescriptionHandler) {
7435
7455
  return;
7436
7456
  }
7437
- logger$4.info('Sending DTMF', {
7457
+ logger$8.info('Sending DTMF', {
7438
7458
  id: this.getSipSessionId(session),
7439
7459
  tone,
7440
7460
  });
@@ -7450,7 +7470,7 @@ class WebRTCClient extends Emitter {
7450
7470
  transfer(session , target ) {
7451
7471
  this.hold(session);
7452
7472
 
7453
- logger$4.info('Transfering a session', {
7473
+ logger$8.info('Transfering a session', {
7454
7474
  id: this.getSipSessionId(session),
7455
7475
  target,
7456
7476
  });
@@ -7472,17 +7492,17 @@ class WebRTCClient extends Emitter {
7472
7492
  atxfer(session ) {
7473
7493
  this.hold(session);
7474
7494
 
7475
- logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7495
+ logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7476
7496
 
7477
7497
  const result = {
7478
7498
  newSession: null,
7479
7499
  init: async (target ) => {
7480
- logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7500
+ logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7481
7501
 
7482
7502
  result.newSession = await this.call(target);
7483
7503
  },
7484
7504
  complete: () => {
7485
- logger$4.info('webrtc transfer completed', {
7505
+ logger$8.info('webrtc transfer completed', {
7486
7506
  id: this.getSipSessionId(session),
7487
7507
  referId: this.getSipSessionId(result.newSession),
7488
7508
  });
@@ -7503,7 +7523,7 @@ class WebRTCClient extends Emitter {
7503
7523
  return;
7504
7524
  }
7505
7525
 
7506
- logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
7526
+ logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7507
7527
 
7508
7528
  try {
7509
7529
  sipSession.message({
@@ -7545,7 +7565,7 @@ class WebRTCClient extends Emitter {
7545
7565
  }
7546
7566
 
7547
7567
  changeAudioOutputVolume(volume ) {
7548
- logger$4.info('Changing audio output volume', { volume });
7568
+ logger$8.info('Changing audio output volume', { volume });
7549
7569
 
7550
7570
  Object.values(this.audioElements).forEach(audioElement => {
7551
7571
  if (audioElement instanceof HTMLAudioElement) {
@@ -7557,7 +7577,7 @@ class WebRTCClient extends Emitter {
7557
7577
  }
7558
7578
 
7559
7579
  changeAudioOutputDevice(id ) {
7560
- logger$4.info('Changing audio output device', { id });
7580
+ logger$8.info('Changing audio output device', { id });
7561
7581
 
7562
7582
  Object.values(this.audioElements).forEach(audioElement => {
7563
7583
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7574,7 +7594,7 @@ class WebRTCClient extends Emitter {
7574
7594
 
7575
7595
  changeAudioInputDevice(id , session ) {
7576
7596
  const currentId = this.getAudioDeviceId();
7577
- logger$4.info('setting audio input device', { id, currentId, session: !!session });
7597
+ logger$8.info('setting audio input device', { id, currentId, session: !!session });
7578
7598
 
7579
7599
  if (id === currentId) {
7580
7600
  return null;
@@ -7620,7 +7640,7 @@ class WebRTCClient extends Emitter {
7620
7640
 
7621
7641
  setVideoInputDevice(id ) {
7622
7642
  const currentId = this.getVideoDeviceId();
7623
- logger$4.info('setting video input device', { id, currentId });
7643
+ logger$8.info('setting video input device', { id, currentId });
7624
7644
 
7625
7645
  if (id === currentId) {
7626
7646
  return null;
@@ -7645,7 +7665,7 @@ class WebRTCClient extends Emitter {
7645
7665
  const sessionId = this.getSipSessionId(session);
7646
7666
  const localStream = this.getLocalStream(sessionId);
7647
7667
 
7648
- logger$4.info('changing video input device', { id, sessionId });
7668
+ logger$8.info('changing video input device', { id, sessionId });
7649
7669
 
7650
7670
  // Release old video stream
7651
7671
  if (localStream) {
@@ -7713,7 +7733,7 @@ class WebRTCClient extends Emitter {
7713
7733
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7714
7734
  const desktop = newConstraints && newConstraints.desktop;
7715
7735
 
7716
- logger$4.info('Sending reinvite', {
7736
+ logger$8.info('Sending reinvite', {
7717
7737
  id: this.getSipSessionId(sipSession),
7718
7738
  newConstraints,
7719
7739
  conference,
@@ -7751,7 +7771,7 @@ class WebRTCClient extends Emitter {
7751
7771
  sipSession.incomingInviteRequest.message.body = response.message.body;
7752
7772
  }
7753
7773
 
7754
- logger$4.info('on re-INVITE accepted', {
7774
+ logger$8.info('on re-INVITE accepted', {
7755
7775
  id: this.getSipSessionId(sipSession),
7756
7776
  wasMuted,
7757
7777
  shouldDoScreenSharing,
@@ -7769,7 +7789,7 @@ class WebRTCClient extends Emitter {
7769
7789
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7770
7790
  }
7771
7791
 
7772
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7792
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7773
7793
  },
7774
7794
  },
7775
7795
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7926,7 +7946,7 @@ class WebRTCClient extends Emitter {
7926
7946
  }
7927
7947
 
7928
7948
  startHeartbeat() {
7929
- logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7949
+ logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7930
7950
  if (!this.userAgent) {
7931
7951
  this.heartbeat.stop();
7932
7952
  return;
@@ -7939,7 +7959,7 @@ class WebRTCClient extends Emitter {
7939
7959
  }
7940
7960
 
7941
7961
  stopHeartbeat() {
7942
- logger$4.info('sdk webrtc stop heartbeat');
7962
+ logger$8.info('sdk webrtc stop heartbeat');
7943
7963
  this.heartbeat.stop();
7944
7964
  }
7945
7965
 
@@ -7960,7 +7980,7 @@ class WebRTCClient extends Emitter {
7960
7980
  }
7961
7981
 
7962
7982
  attemptReconnection() {
7963
- logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
7983
+ logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7964
7984
  if (!this.userAgent) {
7965
7985
  return;
7966
7986
  }
@@ -7985,7 +8005,7 @@ class WebRTCClient extends Emitter {
7985
8005
  return;
7986
8006
  }
7987
8007
 
7988
- logger$4.info('setting local media stream', {
8008
+ logger$8.info('setting local media stream', {
7989
8009
  sipSessionId,
7990
8010
  tracks: newStream ? newStream.getTracks() : null,
7991
8011
  });
@@ -8002,7 +8022,7 @@ class WebRTCClient extends Emitter {
8002
8022
 
8003
8023
  const oldStream = this.getLocalStream(sipSessionId);
8004
8024
 
8005
- logger$4.info('updating local stream', {
8025
+ logger$8.info('updating local stream', {
8006
8026
  sipSessionId,
8007
8027
  oldStream: !!oldStream,
8008
8028
  tracks: newStream.getTracks(),
@@ -8022,7 +8042,7 @@ class WebRTCClient extends Emitter {
8022
8042
  const remoteStream = this.getRemoteStream(sessionId);
8023
8043
  const pc = this.getPeerConnection(sessionId);
8024
8044
 
8025
- logger$4.info('Updating remote stream', {
8045
+ logger$8.info('Updating remote stream', {
8026
8046
  sessionId,
8027
8047
  tracks: remoteStream ? remoteStream.getTracks() : null,
8028
8048
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -8047,14 +8067,16 @@ class WebRTCClient extends Emitter {
8047
8067
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
8048
8068
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
8049
8069
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
8070
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
8050
8071
 
8051
- logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8072
+ logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8052
8073
 
8053
8074
  return {
8054
8075
  constraints: {
8055
8076
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
8056
8077
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
8057
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
8078
+ video: screenSharing ? (isDesktop
8079
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
8058
8080
  : this._getVideoConstraints(enableVideo),
8059
8081
  screen: screenSharing,
8060
8082
  desktop: isDesktop,
@@ -8097,7 +8119,7 @@ class WebRTCClient extends Emitter {
8097
8119
  }
8098
8120
 
8099
8121
  _onTransportError() {
8100
- logger$4.error('on transport error');
8122
+ logger$8.error('on transport error');
8101
8123
  this.eventEmitter.emit(TRANSPORT_ERROR);
8102
8124
  this.attemptReconnection();
8103
8125
  }
@@ -8106,7 +8128,7 @@ class WebRTCClient extends Emitter {
8106
8128
  const body = message && typeof message === 'object' ? message.data : message;
8107
8129
  if (body && body.indexOf('200 OK') !== -1) {
8108
8130
  if (this.hasHeartbeat()) {
8109
- logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8131
+ logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8110
8132
 
8111
8133
  this.heartbeat.onHeartbeat();
8112
8134
  if (this.heartbeatCb) {
@@ -8117,7 +8139,7 @@ class WebRTCClient extends Emitter {
8117
8139
  }
8118
8140
 
8119
8141
  async _onHeartbeatTimeout() {
8120
- logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8142
+ logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8121
8143
 
8122
8144
  if (this.heartbeatTimeoutCb) {
8123
8145
  this.heartbeatTimeoutCb();
@@ -8129,7 +8151,7 @@ class WebRTCClient extends Emitter {
8129
8151
  try {
8130
8152
  await this.userAgent.transport.disconnect();
8131
8153
  } catch (e) {
8132
- logger$4.error('Transport disconnection after heartbeat timeout, error', e);
8154
+ logger$8.error('Transport disconnection after heartbeat timeout, error', e);
8133
8155
  }
8134
8156
  }
8135
8157
 
@@ -8162,31 +8184,31 @@ class WebRTCClient extends Emitter {
8162
8184
  }
8163
8185
 
8164
8186
  _connectIfNeeded() {
8165
- logger$4.info('connect if needed, checking', { connected: this.isConnected() });
8187
+ logger$8.info('connect if needed, checking', { connected: this.isConnected() });
8166
8188
  if (!this.userAgent) {
8167
- logger$4.info('need to recreate User Agent');
8189
+ logger$8.info('need to recreate User Agent');
8168
8190
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
8169
8191
  }
8170
8192
 
8171
8193
  if (this.isConnected()) {
8172
- logger$4.info('webrtc sdk, already connected');
8194
+ logger$8.info('webrtc sdk, already connected');
8173
8195
  return Promise.resolve();
8174
8196
  }
8175
8197
 
8176
8198
  if (this.isConnecting()) {
8177
- logger$4.info('webrtc sdk, already connecting...');
8199
+ logger$8.info('webrtc sdk, already connecting...');
8178
8200
 
8179
8201
  this.connectionPromise = this.userAgent.transport.connectPromise;
8180
8202
  return this.connectionPromise;
8181
8203
  }
8182
8204
 
8183
8205
  if (this.connectionPromise) {
8184
- logger$4.info('webrtc sdk, connection promise connecting...');
8206
+ logger$8.info('webrtc sdk, connection promise connecting...');
8185
8207
  // $FlowFixMe
8186
8208
  return this.connectionPromise;
8187
8209
  }
8188
8210
 
8189
- logger$4.info('WebRTC UA needs to connect');
8211
+ logger$8.info('WebRTC UA needs to connect');
8190
8212
 
8191
8213
  // Force UA to reconnect
8192
8214
  if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
@@ -8311,7 +8333,7 @@ class WebRTCClient extends Emitter {
8311
8333
 
8312
8334
  sdh.peerConnectionDelegate = {
8313
8335
  onicecandidateerror: (error ) => {
8314
- logger$4.error('on icecandidate error', {
8336
+ logger$8.error('on icecandidate error', {
8315
8337
  address: error.address,
8316
8338
  port: error.port,
8317
8339
  errorCode: error.errorCode,
@@ -8340,7 +8362,7 @@ class WebRTCClient extends Emitter {
8340
8362
  updatedNumber = session.assertedIdentity.uri.normal.user;
8341
8363
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8342
8364
  }
8343
- logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8365
+ logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8344
8366
 
8345
8367
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8346
8368
 
@@ -8356,12 +8378,12 @@ class WebRTCClient extends Emitter {
8356
8378
 
8357
8379
  this._setupMedias(session);
8358
8380
 
8359
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8381
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8360
8382
  };
8361
8383
  }
8362
8384
 
8363
8385
  _onAccepted(session , sessionDialog , withEvent = true) {
8364
- logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8386
+ logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8365
8387
 
8366
8388
  this.storeSipSession(session);
8367
8389
 
@@ -8373,14 +8395,14 @@ class WebRTCClient extends Emitter {
8373
8395
  const onTrack = (event ) => {
8374
8396
  const isAudioOnly = this._isAudioOnly(session);
8375
8397
  const { kind, label, readyState, id, muted } = event.track;
8376
- logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8398
+ logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8377
8399
 
8378
8400
  // Stop video track in audio only mode
8379
8401
  if (isAudioOnly && kind === 'video') {
8380
8402
  event.track.stop();
8381
8403
  }
8382
8404
 
8383
- this.eventEmitter.emit(ON_TRACK, session, event);
8405
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
8384
8406
  };
8385
8407
 
8386
8408
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8389,12 +8411,14 @@ class WebRTCClient extends Emitter {
8389
8411
 
8390
8412
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8391
8413
 
8392
- pc.oniceconnectionstatechange = () => {
8393
- logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
8394
- if (pc.iceConnectionState === 'disconnected') {
8395
- this.eventEmitter.emit(ON_DISCONNECTED);
8396
- }
8397
- };
8414
+ if (pc) {
8415
+ pc.oniceconnectionstatechange = () => {
8416
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8417
+ if (pc.iceConnectionState === 'disconnected') {
8418
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8419
+ }
8420
+ };
8421
+ }
8398
8422
 
8399
8423
  if (withEvent) {
8400
8424
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8563,10 +8587,10 @@ class WebRTCClient extends Emitter {
8563
8587
 
8564
8588
  _stopSendingStats(session ) {
8565
8589
  const sessionId = this.getSipSessionId(session);
8566
- logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8590
+ logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8567
8591
 
8568
8592
  if (sessionId in this.statsIntervals) {
8569
- logger$4.trace('Stop sending stats for call', { sessionId });
8593
+ logger$8.trace('Stop sending stats for call', { sessionId });
8570
8594
  this.statsIntervals[sessionId]();
8571
8595
  delete this.statsIntervals[sessionId];
8572
8596
  }
@@ -8582,7 +8606,7 @@ class WebRTCClient extends Emitter {
8582
8606
  try {
8583
8607
  await this.userAgent.transport.disconnect();
8584
8608
  } catch (e) {
8585
- logger$4.error('WebRTC transport disconnect, error', e);
8609
+ logger$8.error('WebRTC transport disconnect, error', e);
8586
8610
  }
8587
8611
  }
8588
8612
  }
@@ -8604,13 +8628,17 @@ class WebRTCClient extends Emitter {
8604
8628
  const nbStats = this.sessionNetworkStats[sessionId].length;
8605
8629
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8606
8630
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8631
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8607
8632
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8608
8633
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8634
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8609
8635
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8610
8636
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8611
8637
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8612
- let audioBytesSent = 0;
8613
- let audioBytesReceived = 0;
8638
+ let audioBytesSent = 0; // content + header
8639
+ let audioBytesReceived = 0; // content + header
8640
+ let audioContentSent = 0; // useful to detect blank call
8641
+ let audioContentReceived = 0;
8614
8642
  let videoBytesSent = 0;
8615
8643
  let videoBytesReceived = 0;
8616
8644
  let transportSent = 0;
@@ -8620,6 +8648,7 @@ class WebRTCClient extends Emitter {
8620
8648
  stats.forEach(report => {
8621
8649
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8622
8650
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8651
+ audioContentSent += Number(report.bytesSent);
8623
8652
  }
8624
8653
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8625
8654
  audioBytesSent += Number(report.bytesSent);
@@ -8631,6 +8660,7 @@ class WebRTCClient extends Emitter {
8631
8660
  packetsLost += Number(report.packetsLost);
8632
8661
  networkStats.packetsReceived = Number(report.packetsReceived);
8633
8662
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8663
+ audioContentReceived += Number(report.bytesReceived);
8634
8664
  }
8635
8665
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8636
8666
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8659,10 +8689,17 @@ class WebRTCClient extends Emitter {
8659
8689
  });
8660
8690
 
8661
8691
  networkStats.packetsLost = packetsLost;
8692
+
8662
8693
  networkStats.totalAudioBytesSent = audioBytesSent;
8663
8694
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8664
8695
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8665
8696
  networkStats.audioBytesReceived = audioBytesReceived;
8697
+
8698
+ networkStats.totalAudioContentSent = audioContentSent;
8699
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8700
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8701
+ networkStats.audioContentReceived = audioContentReceived;
8702
+
8666
8703
  networkStats.totalVideoBytesSent = videoBytesSent;
8667
8704
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8668
8705
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8676,7 +8713,7 @@ class WebRTCClient extends Emitter {
8676
8713
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8677
8714
  + networkStats.transportSent;
8678
8715
 
8679
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8716
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8680
8717
  this.sessionNetworkStats[sessionId].push(networkStats);
8681
8718
  }
8682
8719
 
@@ -8701,11 +8738,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8701
8738
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8702
8739
  const ON_CALL_CANCELED = 'onCallCanceled';
8703
8740
  const ON_CALL_FAILED = 'onCallFailed';
8741
+ const ON_CALL_REJECTED = 'onCallRejected';
8704
8742
  const ON_CALL_ENDED = 'onCallEnded';
8705
8743
  const ON_CALL_ENDING = 'onCallEnding';
8706
8744
  const ON_MESSAGE = 'onMessage';
8707
- const ON_REINVITE$1 = 'reinvite';
8708
- const ON_TRACK$1 = 'onTrack';
8745
+ const ON_REINVITE = 'reinvite';
8746
+ const ON_TRACK = 'onTrack';
8709
8747
  const ON_AUDIO_STREAM = 'onAudioStream';
8710
8748
  const ON_VIDEO_STREAM = 'onVideoStream';
8711
8749
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8720,15 +8758,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8720
8758
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8721
8759
  const ON_CALL_ERROR = 'onCallError';
8722
8760
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8723
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
8761
+ const ON_NETWORK_STATS = 'onNetworkStats';
8724
8762
  const ON_CHAT = 'phone/ON_CHAT';
8725
8763
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8726
- const ON_DISCONNECTED$1 = 'onDisconnected';
8764
+ const ON_DISCONNECTED = 'onDisconnected';
8727
8765
 
8728
8766
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8729
8767
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8730
8768
 
8731
- const events$1 = [
8769
+ const events = [
8732
8770
  ON_USER_AGENT,
8733
8771
  ON_REGISTERED,
8734
8772
  ON_UNREGISTERED,
@@ -8745,9 +8783,10 @@ const events$1 = [
8745
8783
  ON_CAMERA_DISABLED,
8746
8784
  ON_CALL_FAILED,
8747
8785
  ON_CALL_ENDED,
8786
+ ON_CALL_REJECTED,
8748
8787
  ON_MESSAGE,
8749
- ON_REINVITE$1,
8750
- ON_TRACK$1,
8788
+ ON_REINVITE,
8789
+ ON_TRACK,
8751
8790
  ON_AUDIO_STREAM,
8752
8791
  ON_VIDEO_STREAM,
8753
8792
  ON_REMOVE_STREAM,
@@ -8762,11 +8801,11 @@ const events$1 = [
8762
8801
  ON_CALL_ERROR,
8763
8802
  ON_CHAT,
8764
8803
  ON_SIGNAL,
8765
- ON_NETWORK_STATS$1,
8766
- ON_DISCONNECTED$1,
8804
+ ON_NETWORK_STATS,
8805
+ ON_DISCONNECTED,
8767
8806
  ];
8768
8807
 
8769
- const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
8808
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8770
8809
 
8771
8810
  class WebRTCPhone extends Emitter {
8772
8811
 
@@ -8839,7 +8878,7 @@ class WebRTCPhone extends Emitter {
8839
8878
  }).catch(error => {
8840
8879
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8841
8880
  console.error('register error', error, error.message, error.stack);
8842
- logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
8881
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8843
8882
  });
8844
8883
  }
8845
8884
 
@@ -8854,7 +8893,7 @@ class WebRTCPhone extends Emitter {
8854
8893
  if (!this.client) {
8855
8894
  return;
8856
8895
  }
8857
- logger$5.info('WebRTC phone stop');
8896
+ logger$7.info('WebRTC phone stop');
8858
8897
  this.client.stop();
8859
8898
  }
8860
8899
 
@@ -8869,11 +8908,12 @@ class WebRTCPhone extends Emitter {
8869
8908
  async sendReinvite(callSession , constraints = null, conference = false,
8870
8909
  audioOnly = false, iceRestart = false) {
8871
8910
  const sipSession = this.findSipSession(callSession);
8872
- logger$5.info('WebRTC phone - send reinvite', {
8911
+ logger$7.info('WebRTC phone - send reinvite', {
8873
8912
  sessionId: sipSession ? sipSession.id : null,
8874
8913
  constraints,
8875
8914
  audioOnly,
8876
8915
  conference,
8916
+ iceRestart,
8877
8917
  });
8878
8918
 
8879
8919
  if (!sipSession) {
@@ -8906,7 +8946,7 @@ class WebRTCPhone extends Emitter {
8906
8946
  }
8907
8947
 
8908
8948
  startHeartbeat() {
8909
- logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8949
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8910
8950
  if (!this.client || this.client.hasHeartbeat()) {
8911
8951
  return;
8912
8952
  }
@@ -8915,7 +8955,7 @@ class WebRTCPhone extends Emitter {
8915
8955
  }
8916
8956
 
8917
8957
  stopHeartbeat() {
8918
- logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8958
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8919
8959
  if (!this.client) {
8920
8960
  return;
8921
8961
  }
@@ -8932,7 +8972,7 @@ class WebRTCPhone extends Emitter {
8932
8972
  }
8933
8973
 
8934
8974
  reconnect() {
8935
- logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
8975
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8936
8976
  if (!this.client) {
8937
8977
  return;
8938
8978
  }
@@ -8973,7 +9013,7 @@ class WebRTCPhone extends Emitter {
8973
9013
  return false;
8974
9014
  }
8975
9015
 
8976
- logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9016
+ logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8977
9017
 
8978
9018
  this.client.downgradeToAudio(sipSession);
8979
9019
 
@@ -8996,7 +9036,7 @@ class WebRTCPhone extends Emitter {
8996
9036
  return Promise.resolve(false);
8997
9037
  }
8998
9038
 
8999
- logger$5.info('Upgrade to video', {
9039
+ logger$7.info('Upgrade to video', {
9000
9040
  id: callSession ? callSession.getId() : null,
9001
9041
  constraints,
9002
9042
  isConference,
@@ -9036,7 +9076,7 @@ class WebRTCPhone extends Emitter {
9036
9076
 
9037
9077
  _sendReinviteMessage(callSession , isUpgrade ) {
9038
9078
  const sipSession = this.findSipSession(callSession);
9039
- logger$5.info('Sending reinvite message', {
9079
+ logger$7.info('Sending reinvite message', {
9040
9080
  id: callSession ? callSession.getId() : null,
9041
9081
  isUpgrade,
9042
9082
  });
@@ -9062,7 +9102,7 @@ class WebRTCPhone extends Emitter {
9062
9102
  // Monkey patch to know when canceled with the CANCEL message
9063
9103
  const onCancel = sipSession._onCancel.bind(sipSession);
9064
9104
  sipSession._onCancel = (message ) => {
9065
- logger$5.trace('on sip session canceled', { callId: message.callId });
9105
+ logger$7.trace('on sip session canceled', { callId: message.callId });
9066
9106
 
9067
9107
  onCancel(message);
9068
9108
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -9090,16 +9130,17 @@ class WebRTCPhone extends Emitter {
9090
9130
  this.audioOutputVolume,
9091
9131
  );
9092
9132
  case SessionState.Terminating:
9093
- logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9133
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9094
9134
 
9095
9135
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9096
9136
 
9097
9137
  break;
9098
9138
  case SessionState.Terminated: {
9099
- logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9139
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9100
9140
 
9101
9141
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9102
9142
  const callSession = this._createCallSession(sipSession);
9143
+ callSession.endTime = new Date();
9103
9144
  const wasCurrentSession = this._onCallTerminated(sipSession);
9104
9145
 
9105
9146
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9118,7 +9159,7 @@ class WebRTCPhone extends Emitter {
9118
9159
  const [stream] = event.streams;
9119
9160
  const kind = event && event.track && event.track.kind;
9120
9161
 
9121
- logger$5.info('on track stream called on the peer connection', {
9162
+ logger$7.info('on track stream called on the peer connection', {
9122
9163
  callId: this.getSipSessionId(sipSession),
9123
9164
  streamId: stream ? stream.id : null,
9124
9165
  tracks: stream ? stream.getTracks() : null,
@@ -9138,7 +9179,7 @@ class WebRTCPhone extends Emitter {
9138
9179
  };
9139
9180
 
9140
9181
  peerConnection.onremovestream = event => {
9141
- logger$5.info('on remove stream called on the peer connection', {
9182
+ logger$7.info('on remove stream called on the peer connection', {
9142
9183
  id: event.stream.id,
9143
9184
  tracks: event.stream.getTracks(),
9144
9185
  });
@@ -9148,7 +9189,7 @@ class WebRTCPhone extends Emitter {
9148
9189
  }
9149
9190
 
9150
9191
  async startScreenSharing(constraints , callSession ) {
9151
- logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9192
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9152
9193
 
9153
9194
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9154
9195
  if (!screenShareStream) {
@@ -9188,7 +9229,7 @@ class WebRTCPhone extends Emitter {
9188
9229
  return;
9189
9230
  }
9190
9231
 
9191
- logger$5.info('WebRTC phone - stop screen sharing', {
9232
+ logger$7.info('WebRTC phone - stop screen sharing', {
9192
9233
  restoreLocalStream,
9193
9234
  });
9194
9235
 
@@ -9244,7 +9285,7 @@ class WebRTCPhone extends Emitter {
9244
9285
  const pc = this.client.getPeerConnection(sipSessionId);
9245
9286
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9246
9287
 
9247
- logger$5.info('WebRTC phone - on screensharing', {
9288
+ logger$7.info('WebRTC phone - on screensharing', {
9248
9289
  hadVideo,
9249
9290
  id: this.getSipSessionId(sipSession),
9250
9291
  screenTrack,
@@ -9252,7 +9293,7 @@ class WebRTCPhone extends Emitter {
9252
9293
 
9253
9294
  if (screenTrack) {
9254
9295
  screenTrack.onended = () => {
9255
- logger$5.info('WebRTC phone - on screenshare ended', {
9296
+ logger$7.info('WebRTC phone - on screenshare ended', {
9256
9297
  hadVideo,
9257
9298
  id: this.getSipSessionId(sipSession),
9258
9299
  screenTrack,
@@ -9283,7 +9324,7 @@ class WebRTCPhone extends Emitter {
9283
9324
  }
9284
9325
 
9285
9326
  _onCallAccepted(sipSession , cameraEnabled ) {
9286
- logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9327
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9287
9328
 
9288
9329
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9289
9330
  this.currentSipSession = sipSession;
@@ -9301,7 +9342,7 @@ class WebRTCPhone extends Emitter {
9301
9342
  }
9302
9343
 
9303
9344
  changeAudioDevice(id ) {
9304
- logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9345
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9305
9346
  this.audioOutputDeviceId = id;
9306
9347
  this.client.changeAudioOutputDevice(id);
9307
9348
  }
@@ -9311,14 +9352,14 @@ class WebRTCPhone extends Emitter {
9311
9352
  }
9312
9353
 
9313
9354
  changeRingDevice(id ) {
9314
- logger$5.info('WebRTC phone - changing ring device', { id });
9355
+ logger$7.info('WebRTC phone - changing ring device', { id });
9315
9356
 
9316
9357
  this.audioRingDeviceId = id;
9317
9358
  }
9318
9359
 
9319
9360
  // volume is a value between 0 and 1
9320
9361
  changeAudioVolume(volume ) {
9321
- logger$5.info('WebRTC phone - changing audio volume', { volume });
9362
+ logger$7.info('WebRTC phone - changing audio volume', { volume });
9322
9363
 
9323
9364
  this.audioOutputVolume = volume;
9324
9365
  this.client.changeAudioOutputVolume(volume);
@@ -9326,32 +9367,33 @@ class WebRTCPhone extends Emitter {
9326
9367
 
9327
9368
  // volume is a value between 0 and 1
9328
9369
  changeRingVolume(volume ) {
9329
- logger$5.info('WebRTC phone - changing ring volume', { volume });
9370
+ logger$7.info('WebRTC phone - changing ring volume', { volume });
9330
9371
 
9331
9372
  this.audioRingVolume = volume;
9332
9373
  }
9333
9374
 
9334
9375
  changeAudioInputDevice(id ) {
9335
- logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9376
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9336
9377
 
9337
9378
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9338
9379
  }
9339
9380
 
9340
9381
  changeVideoInputDevice(id ) {
9341
- logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9382
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9342
9383
 
9343
9384
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9344
9385
  }
9345
9386
 
9346
9387
  changeSessionVideoInputDevice(id ) {
9347
- logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9388
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9348
9389
 
9349
9390
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9350
9391
  }
9351
9392
 
9352
9393
  _onCallTerminated(sipSession ) {
9353
- logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9394
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9354
9395
 
9396
+ const sipSessionId = this.getSipSessionId(sipSession);
9355
9397
  const callSession = this._createCallSession(sipSession);
9356
9398
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9357
9399
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9369,7 +9411,6 @@ class WebRTCPhone extends Emitter {
9369
9411
  }, 5);
9370
9412
  }
9371
9413
 
9372
- const sipSessionId = this.getSipSessionId(sipSession);
9373
9414
  if (sipSessionId) {
9374
9415
  this.removeIncomingSessions(sipSessionId);
9375
9416
  }
@@ -9384,7 +9425,7 @@ class WebRTCPhone extends Emitter {
9384
9425
  const hasIncomingCallSession = this.hasIncomingCallSession();
9385
9426
 
9386
9427
  // Re-trigger incoming call event for remaining incoming calls
9387
- logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9428
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9388
9429
  sipId: sipSession.id,
9389
9430
  shouldRetrigger,
9390
9431
  hasIncomingCallSession,
@@ -9475,37 +9516,37 @@ class WebRTCPhone extends Emitter {
9475
9516
 
9476
9517
  // Deprecated
9477
9518
  getLocalStreamForCall(callSession ) {
9478
- logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9519
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9479
9520
 
9480
9521
  return this.getLocalStream(callSession);
9481
9522
  }
9482
9523
 
9483
9524
  // Deprecated
9484
9525
  getRemoteStreamForCall(callSession ) {
9485
- logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9526
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9486
9527
 
9487
9528
  return this.getRemoteVideoStream(callSession);
9488
9529
  }
9489
9530
 
9490
9531
  getRemoteStreamsForCall(callSession ) {
9491
- logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9532
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9492
9533
 
9493
9534
  return this.getRemoteStream(callSession);
9494
9535
  }
9495
9536
 
9496
9537
  accept(callSession , cameraEnabled ) {
9497
- logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9538
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9498
9539
  if (this.currentSipSession) {
9499
9540
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9500
9541
  }
9501
9542
 
9502
9543
  if (!callSession) {
9503
- logger$5.warn('no CallSession to accept.');
9544
+ logger$7.warn('no CallSession to accept.');
9504
9545
  return Promise.resolve(null);
9505
9546
  }
9506
9547
 
9507
9548
  if (callSession.getId() in this.acceptedSessions) {
9508
- logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9549
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9509
9550
  return Promise.resolve(callSession.sipCallId);
9510
9551
  }
9511
9552
 
@@ -9517,24 +9558,24 @@ class WebRTCPhone extends Emitter {
9517
9558
  const sipSession = this.client.getSipSession(callSession.getId());
9518
9559
  if (sipSession) {
9519
9560
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
9520
- logger$5.warn('Trying to answer a terminated sipSession.');
9561
+ logger$7.warn('Trying to answer a terminated sipSession.');
9521
9562
 
9522
9563
  return Promise.resolve(null);
9523
9564
  }
9524
9565
 
9525
- logger$5.info('accept call, session found', { sipId: sipSession.id });
9566
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
9526
9567
 
9527
9568
  // $FlowFixMe
9528
9569
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9529
9570
  return callSession.sipCallId;
9530
9571
  }).catch(e => {
9531
- logger$5.error(e);
9572
+ logger$7.error(e);
9532
9573
  this.endCurrentCall(callSession);
9533
9574
  throw e;
9534
9575
  });
9535
9576
  }
9536
9577
 
9537
- logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9578
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9538
9579
 
9539
9580
  return Promise.resolve(null);
9540
9581
  }
@@ -9544,7 +9585,7 @@ class WebRTCPhone extends Emitter {
9544
9585
  }
9545
9586
 
9546
9587
  async reject(callSession ) {
9547
- logger$5.info('reject WebRTC called', { id: callSession.getId() });
9588
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
9548
9589
 
9549
9590
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9550
9591
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9556,14 +9597,14 @@ class WebRTCPhone extends Emitter {
9556
9597
 
9557
9598
  const sipSession = this.findSipSession(callSession);
9558
9599
  if (sipSession) {
9559
- logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9600
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
9560
9601
 
9561
9602
  this.client.hangup(sipSession);
9562
9603
  }
9563
9604
  }
9564
9605
 
9565
9606
  async ignore(callSession ) {
9566
- logger$5.info('WebRTC ignore', { id: callSession.getId() });
9607
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
9567
9608
 
9568
9609
  // kill the ring
9569
9610
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9575,14 +9616,14 @@ class WebRTCPhone extends Emitter {
9575
9616
  const sipSession = this.findSipSession(callSession);
9576
9617
 
9577
9618
  if (sipSession) {
9578
- logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9619
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
9579
9620
 
9580
9621
  return this.client.atxfer(sipSession);
9581
9622
  }
9582
9623
  }
9583
9624
 
9584
9625
  hold(callSession , withEvent = true, isConference = false) {
9585
- logger$5.info('WebRTC hold', { id: callSession.getId() });
9626
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
9586
9627
 
9587
9628
  const sipSession = this.findSipSession(callSession);
9588
9629
 
@@ -9597,18 +9638,18 @@ class WebRTCPhone extends Emitter {
9597
9638
  }
9598
9639
 
9599
9640
  resume(callSession , isConference = false, withEvent = true) {
9600
- logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9641
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9601
9642
 
9602
9643
  const sipSession = this.findSipSession(callSession);
9603
9644
  if (!sipSession) {
9604
9645
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9605
9646
  }
9606
9647
 
9607
- logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9648
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
9608
9649
 
9609
9650
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9610
9651
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9611
- logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9652
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9612
9653
  this.holdSipSession(this.currentSipSession, callSession);
9613
9654
  }
9614
9655
 
@@ -9633,7 +9674,7 @@ class WebRTCPhone extends Emitter {
9633
9674
  const sessionId = this.getSipSessionId(sipSession);
9634
9675
  const hasVideo = this.client.hasLocalVideo(sessionId);
9635
9676
 
9636
- logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9677
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9637
9678
 
9638
9679
  // Stop screenshre if needed
9639
9680
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9664,7 +9705,7 @@ class WebRTCPhone extends Emitter {
9664
9705
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9665
9706
  }
9666
9707
  const sessionId = this.getSipSessionId(sipSession);
9667
- logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
9708
+ logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9668
9709
 
9669
9710
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9670
9711
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9708,14 +9749,14 @@ class WebRTCPhone extends Emitter {
9708
9749
  }
9709
9750
 
9710
9751
  mute(callSession , withEvent = true) {
9711
- logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9752
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9712
9753
 
9713
9754
  const sipSession = this.findSipSession(callSession);
9714
9755
  if (!sipSession) {
9715
9756
  return;
9716
9757
  }
9717
9758
 
9718
- logger$5.info('WebRTC muting', { sipId: sipSession.id });
9759
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
9719
9760
  this.client.mute(sipSession);
9720
9761
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9721
9762
 
@@ -9729,14 +9770,14 @@ class WebRTCPhone extends Emitter {
9729
9770
  }
9730
9771
 
9731
9772
  unmute(callSession , withEvent = true) {
9732
- logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9773
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9733
9774
 
9734
9775
  const sipSession = this.findSipSession(callSession);
9735
9776
  if (!sipSession) {
9736
9777
  return;
9737
9778
  }
9738
9779
 
9739
- logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
9780
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9740
9781
  this.client.unmute(sipSession);
9741
9782
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9742
9783
 
@@ -9763,7 +9804,7 @@ class WebRTCPhone extends Emitter {
9763
9804
  if (!sipSession) {
9764
9805
  return;
9765
9806
  }
9766
- logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
9807
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9767
9808
 
9768
9809
  this.client.toggleCameraOn(sipSession);
9769
9810
 
@@ -9775,7 +9816,7 @@ class WebRTCPhone extends Emitter {
9775
9816
  if (!sipSession) {
9776
9817
  return;
9777
9818
  }
9778
- logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
9819
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9779
9820
 
9780
9821
  this.client.toggleCameraOff(sipSession);
9781
9822
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9787,7 +9828,7 @@ class WebRTCPhone extends Emitter {
9787
9828
  return;
9788
9829
  }
9789
9830
 
9790
- logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
9831
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9791
9832
  this.client.sendDTMF(sipSession, tone);
9792
9833
  }
9793
9834
 
@@ -9795,7 +9836,7 @@ class WebRTCPhone extends Emitter {
9795
9836
  // @TODO: line is not used here
9796
9837
  async makeCall(number , line , cameraEnabled ,
9797
9838
  audioOnly = false, conference = false) {
9798
- logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9839
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
9799
9840
  if (!number) {
9800
9841
  return Promise.resolve(null);
9801
9842
  }
@@ -9805,7 +9846,7 @@ class WebRTCPhone extends Emitter {
9805
9846
  }
9806
9847
  if (this.currentSipSession) {
9807
9848
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9808
- logger$5.warn('Unable to hold current session when making another call', e);
9849
+ logger$7.warn('Unable to hold current session when making another call', e);
9809
9850
  });
9810
9851
  }
9811
9852
 
@@ -9815,10 +9856,11 @@ class WebRTCPhone extends Emitter {
9815
9856
  this._bindEvents(sipSession);
9816
9857
  } catch (error) {
9817
9858
  console.warn(error);
9818
- logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9859
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9819
9860
  return Promise.resolve(null);
9820
9861
  }
9821
9862
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9863
+ callSession.creationTime = new Date();
9822
9864
 
9823
9865
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9824
9866
 
@@ -9843,7 +9885,7 @@ class WebRTCPhone extends Emitter {
9843
9885
  return;
9844
9886
  }
9845
9887
 
9846
- logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
9888
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9847
9889
 
9848
9890
  this.client.transfer(sipSession, target);
9849
9891
  }
@@ -9852,7 +9894,7 @@ class WebRTCPhone extends Emitter {
9852
9894
  const sipSession = this.client.getSipSession(source.sipCallId);
9853
9895
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9854
9896
 
9855
- logger$5.info('WebRTC indirect transfer', {
9897
+ logger$7.info('WebRTC indirect transfer', {
9856
9898
  sipId: sipSession ? sipSession.id : null,
9857
9899
  target: sipSessionTarget ? sipSessionTarget.id : null,
9858
9900
  });
@@ -9891,7 +9933,7 @@ class WebRTCPhone extends Emitter {
9891
9933
  return false;
9892
9934
  }
9893
9935
 
9894
- logger$5.info('WebRTC hangup', { sipId: sipSession.id });
9936
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9895
9937
 
9896
9938
  const sipSessionId = this.getSipSessionId(sipSession);
9897
9939
 
@@ -9937,7 +9979,7 @@ class WebRTCPhone extends Emitter {
9937
9979
  endCurrentCall(callSession ) {
9938
9980
  const isCurrent = this.isCurrentCallSipSession(callSession);
9939
9981
 
9940
- logger$5.info('Ending current call', {
9982
+ logger$7.info('Ending current call', {
9941
9983
  id: callSession ? callSession.getId() : null,
9942
9984
  isCurrent,
9943
9985
  });
@@ -9961,7 +10003,7 @@ class WebRTCPhone extends Emitter {
9961
10003
  }
9962
10004
 
9963
10005
  async close() {
9964
- logger$5.info('WebRTC close');
10006
+ logger$7.info('WebRTC close');
9965
10007
 
9966
10008
  try {
9967
10009
  await Promise.race([
@@ -9969,7 +10011,7 @@ class WebRTCPhone extends Emitter {
9969
10011
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9970
10012
  ]);
9971
10013
  } catch (e) {
9972
- logger$5.error('WebRTC close, unregister error', e);
10014
+ logger$7.error('WebRTC close, unregister error', e);
9973
10015
  }
9974
10016
 
9975
10017
  this.client.close();
@@ -9987,12 +10029,12 @@ class WebRTCPhone extends Emitter {
9987
10029
  }
9988
10030
 
9989
10031
  enableRinging() {
9990
- logger$5.info('WebRTC enable ringing');
10032
+ logger$7.info('WebRTC enable ringing');
9991
10033
  this.ringingEnabled = true;
9992
10034
  }
9993
10035
 
9994
10036
  disableRinging() {
9995
- logger$5.info('WebRTC disable ringing');
10037
+ logger$7.info('WebRTC disable ringing');
9996
10038
  this.ringingEnabled = false;
9997
10039
  }
9998
10040
 
@@ -10014,8 +10056,12 @@ class WebRTCPhone extends Emitter {
10014
10056
  }
10015
10057
 
10016
10058
  const sessionId = this.incomingSessions[0];
10059
+ const sipSession = this.client.getSipSession(sessionId);
10060
+ if (!sipSession) {
10061
+ return null;
10062
+ }
10017
10063
 
10018
- return this._createCallSession(this.client.getSipSession(sessionId));
10064
+ return this._createCallSession(sipSession);
10019
10065
  }
10020
10066
 
10021
10067
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10032,7 +10078,7 @@ class WebRTCPhone extends Emitter {
10032
10078
 
10033
10079
  // Deprecated
10034
10080
  getLocalMediaStream(callSession ) {
10035
- logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10081
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10036
10082
  return this.getLocalStream(callSession);
10037
10083
  }
10038
10084
 
@@ -10074,7 +10120,7 @@ class WebRTCPhone extends Emitter {
10074
10120
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10075
10121
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10076
10122
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10077
- logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10123
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10078
10124
 
10079
10125
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10080
10126
  this.incomingSessions.push(callSession.getId());
@@ -10093,11 +10139,12 @@ class WebRTCPhone extends Emitter {
10093
10139
  callSession);
10094
10140
  }
10095
10141
 
10142
+ callSession.creationTime = new Date();
10096
10143
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10097
10144
  });
10098
10145
 
10099
10146
  this.client.on(this.client.ON_REINVITE, (...args) => {
10100
- logger$5.info('WebRTC on reinvite', {
10147
+ logger$7.info('WebRTC on reinvite', {
10101
10148
  sessionId: args[0].id,
10102
10149
  inviteId: args[1].id,
10103
10150
  updatedCalleeName: args[2],
@@ -10117,7 +10164,7 @@ class WebRTCPhone extends Emitter {
10117
10164
  });
10118
10165
 
10119
10166
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10120
- logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10167
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10121
10168
 
10122
10169
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10123
10170
 
@@ -10128,22 +10175,29 @@ class WebRTCPhone extends Emitter {
10128
10175
  this.client.on('ended', () => {});
10129
10176
 
10130
10177
  this.client.on(this.client.ON_ERROR, e => {
10131
- logger$5.error('WebRTC error', e);
10178
+ logger$7.error('WebRTC error', e);
10132
10179
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10133
10180
  });
10134
10181
 
10182
+ this.client.on(this.client.REJECTED, session => {
10183
+ logger$7.info('WebRTC call rejected', session.id);
10184
+ const callSession = this._createCallSession(session);
10185
+ callSession.endTime = new Date();
10186
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10187
+ });
10188
+
10135
10189
  this.client.on(this.client.UNREGISTERED, () => {
10136
- logger$5.info('WebRTC unregistered');
10190
+ logger$7.info('WebRTC unregistered');
10137
10191
  this.eventEmitter.emit(ON_UNREGISTERED);
10138
10192
  });
10139
10193
 
10140
10194
  this.client.on(this.client.ON_DISCONNECTED, () => {
10141
- logger$5.info('WebRTC disconnected');
10142
- this.eventEmitter.emit(ON_DISCONNECTED$1);
10195
+ logger$7.info('WebRTC disconnected');
10196
+ this.eventEmitter.emit(ON_DISCONNECTED);
10143
10197
  });
10144
10198
 
10145
10199
  this.client.on(this.client.REGISTERED, () => {
10146
- logger$5.info('WebRTC registered', {
10200
+ logger$7.info('WebRTC registered', {
10147
10201
  shouldSendReinvite: this.shouldSendReinvite,
10148
10202
  state: this.currentSipSession ? this.currentSipSession.state : null,
10149
10203
  currentSipSession: !!this.currentSipSession,
@@ -10164,19 +10218,19 @@ class WebRTCPhone extends Emitter {
10164
10218
  // Send reinvite with iceRestart
10165
10219
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10166
10220
  } catch (e) {
10167
- logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10221
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10168
10222
  }
10169
10223
  }
10170
10224
  });
10171
10225
 
10172
10226
  this.client.on(this.client.CONNECTED, () => {
10173
- logger$5.info('WebRTC client connected');
10227
+ logger$7.info('WebRTC client connected');
10174
10228
 
10175
10229
  this.stopHeartbeat();
10176
10230
  });
10177
10231
 
10178
10232
  this.client.on(this.client.DISCONNECTED, () => {
10179
- logger$5.info('WebRTC client disconnected');
10233
+ logger$7.info('WebRTC client disconnected');
10180
10234
 
10181
10235
  this.eventEmitter.emit(ON_UNREGISTERED);
10182
10236
 
@@ -10190,7 +10244,7 @@ class WebRTCPhone extends Emitter {
10190
10244
  });
10191
10245
 
10192
10246
  this.client.on(this.client.ON_TRACK, (session, event) => {
10193
- this.eventEmitter.emit(ON_TRACK$1, session, event);
10247
+ this.eventEmitter.emit(ON_TRACK, session, event);
10194
10248
  });
10195
10249
 
10196
10250
  this.client.on('onVideoInputChange', stream => {
@@ -10205,7 +10259,7 @@ class WebRTCPhone extends Emitter {
10205
10259
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10206
10260
  const callSession = this.getCallSession(this.getSipSessionId(session));
10207
10261
 
10208
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10262
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10209
10263
  });
10210
10264
 
10211
10265
  // Used when upgrading directly in screenshare mode
@@ -10214,7 +10268,7 @@ class WebRTCPhone extends Emitter {
10214
10268
  const localStream = this.client.getLocalStream(sipSessionId);
10215
10269
  const callSession = this.callSessions[sipSessionId];
10216
10270
 
10217
- logger$5.info('Updrading directly in screensharing mode', {
10271
+ logger$7.info('Updrading directly in screensharing mode', {
10218
10272
  sipSessionId,
10219
10273
  tracks: localStream ? localStream.getTracks() : null,
10220
10274
  });
@@ -10344,6 +10398,7 @@ class WebRTCPhone extends Emitter {
10344
10398
  const number = identity ? identity.uri._normal.user : null;
10345
10399
  const { state } = sipSession || {};
10346
10400
  const sessionId = this.getSipSessionId(sipSession);
10401
+ fromSession = fromSession || this.callSessions[sessionId];
10347
10402
 
10348
10403
  const callSession = new CallSession({
10349
10404
  callId: fromSession && fromSession.callId,
@@ -10351,6 +10406,8 @@ class WebRTCPhone extends Emitter {
10351
10406
  sipStatus: state,
10352
10407
  displayName: identity ? identity.displayName || number : number,
10353
10408
  startTime: fromSession ? fromSession.startTime : new Date(),
10409
+ creationTime: fromSession ? fromSession.creationTime : null,
10410
+ endTime: fromSession ? fromSession.endTime : null,
10354
10411
  answered: state === SessionState.Established,
10355
10412
  paused: this.client.isCallHeld(sipSession),
10356
10413
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10361,6 +10418,7 @@ class WebRTCPhone extends Emitter {
10361
10418
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10362
10419
  recording: fromSession ? fromSession.isRecording() : false,
10363
10420
  recordingPaused: false, // @TODO
10421
+ sipSession,
10364
10422
  ...extra,
10365
10423
  });
10366
10424
 
@@ -10389,11 +10447,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10389
10447
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10390
10448
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10391
10449
  ON_CALL_FAILED: ON_CALL_FAILED,
10450
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10392
10451
  ON_CALL_ENDED: ON_CALL_ENDED,
10393
10452
  ON_CALL_ENDING: ON_CALL_ENDING,
10394
10453
  ON_MESSAGE: ON_MESSAGE,
10395
- ON_REINVITE: ON_REINVITE$1,
10396
- ON_TRACK: ON_TRACK$1,
10454
+ ON_REINVITE: ON_REINVITE,
10455
+ ON_TRACK: ON_TRACK,
10397
10456
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10398
10457
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10399
10458
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10408,16 +10467,24 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10408
10467
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10409
10468
  ON_CALL_ERROR: ON_CALL_ERROR,
10410
10469
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10411
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10470
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10412
10471
  ON_CHAT: ON_CHAT,
10413
10472
  ON_SIGNAL: ON_SIGNAL,
10414
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10473
+ ON_DISCONNECTED: ON_DISCONNECTED,
10415
10474
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10416
10475
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10417
- events: events$1,
10476
+ events: events,
10418
10477
  'default': WebRTCPhone
10419
10478
  });
10420
10479
 
10480
+ /* */
10481
+ class SFUNotAvailableError extends Error {
10482
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10483
+ super(message);
10484
+ this.name = 'SFUNotAvailableError';
10485
+ }
10486
+ }
10487
+
10421
10488
  //
10422
10489
 
10423
10490
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10802,13 +10869,13 @@ class Phone extends Emitter {
10802
10869
 
10803
10870
  checkSfu() {
10804
10871
  if (!this.hasSfu()) {
10805
- throw new Error('Sorry your user is not configured to support video conference');
10872
+ throw new SFUNotAvailableError();
10806
10873
  }
10807
10874
  }
10808
10875
 
10809
10876
  _transferEvents() {
10810
10877
  this.unbind();
10811
- [...events, ...transportEvents].forEach(event => {
10878
+ [...events$1, ...transportEvents].forEach(event => {
10812
10879
  this.client.on(event, (...args) =>
10813
10880
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10814
10881
  });
@@ -10830,7 +10897,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10830
10897
 
10831
10898
  //
10832
10899
 
10833
- const SOCKET_EVENTS = {
10900
+ const SOCKET_EVENTS$1 = {
10834
10901
  ON_OPEN: 'onopen',
10835
10902
  ON_MESSAGE: 'onmessage',
10836
10903
  ON_ERROR: 'onerror',
@@ -10926,7 +10993,7 @@ const BLACKLIST_EVENTS = [
10926
10993
  ];
10927
10994
 
10928
10995
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10929
- const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
10996
+ const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10930
10997
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10931
10998
 
10932
10999
  class WebSocketClient extends Emitter {
@@ -10975,24 +11042,24 @@ class WebSocketClient extends Emitter {
10975
11042
  }
10976
11043
 
10977
11044
  connect() {
10978
- logger$7.info('connect method started', { host: this.host, token: this.token });
11045
+ logger$5.info('connect method started', { host: this.host, token: this.token });
10979
11046
  this.socket = new ReconnectingWebSocket(this._getUrl.bind(this), [], this.options);
10980
11047
  if (this.options.binaryType) {
10981
11048
  this.socket.binaryType = this.options.binaryType;
10982
11049
  }
10983
11050
 
10984
11051
  this.socket.onopen = () => {
10985
- logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
10986
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
11052
+ logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
11053
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10987
11054
  };
10988
11055
 
10989
11056
  this.socket.onerror = event => {
10990
- logger$7.error('on Wazo WS error', event.target);
10991
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
11057
+ logger$5.error('on Wazo WS error', event.target);
11058
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10992
11059
  };
10993
11060
 
10994
11061
  this.socket.onmessage = (event ) => {
10995
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
11062
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
10996
11063
 
10997
11064
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10998
11065
  let { name } = message;
@@ -11017,7 +11084,7 @@ class WebSocketClient extends Emitter {
11017
11084
 
11018
11085
  this.socket.onclose = event => {
11019
11086
  // Can't be converted to JSON (circular structure)
11020
- logger$7.info('on Wazo WS close', {
11087
+ logger$5.info('on Wazo WS close', {
11021
11088
  reason: event.reason,
11022
11089
  code: event.code,
11023
11090
  readyState: event.target.readyState,
@@ -11025,22 +11092,22 @@ class WebSocketClient extends Emitter {
11025
11092
  token: this.token,
11026
11093
  });
11027
11094
  this.initialized = false;
11028
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
11095
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
11029
11096
 
11030
11097
  switch (event.code) {
11031
11098
  case 4002:
11032
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
11099
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
11033
11100
  break;
11034
11101
  }
11035
11102
  };
11036
11103
 
11037
11104
  this.socket.onerror = event => {
11038
- logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11105
+ logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11039
11106
  };
11040
11107
  }
11041
11108
 
11042
11109
  close(force = false) {
11043
- logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11110
+ logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11044
11111
 
11045
11112
  if (!this.socket) {
11046
11113
  return;
@@ -11058,7 +11125,7 @@ class WebSocketClient extends Emitter {
11058
11125
 
11059
11126
  updateToken(token ) {
11060
11127
  this.token = token;
11061
- logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11128
+ logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11062
11129
 
11063
11130
  if (this.socket) {
11064
11131
  // If still connected, send the token to the WS
@@ -11076,7 +11143,7 @@ class WebSocketClient extends Emitter {
11076
11143
  }
11077
11144
 
11078
11145
  startHeartbeat() {
11079
- logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11146
+ logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11080
11147
 
11081
11148
  if (!this.socket) {
11082
11149
  this.heartbeat.stop();
@@ -11090,7 +11157,7 @@ class WebSocketClient extends Emitter {
11090
11157
  }
11091
11158
 
11092
11159
  stopHeartbeat() {
11093
- logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11160
+ logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11094
11161
 
11095
11162
  this.heartbeat.stop();
11096
11163
  }
@@ -11120,7 +11187,7 @@ class WebSocketClient extends Emitter {
11120
11187
  }
11121
11188
 
11122
11189
  reconnect(reason ) {
11123
- logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11190
+ logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11124
11191
  if (!this.socket) {
11125
11192
  return;
11126
11193
  }
@@ -11145,7 +11212,7 @@ class WebSocketClient extends Emitter {
11145
11212
  break;
11146
11213
  case 'start':
11147
11214
  this.initialized = true;
11148
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
11215
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
11149
11216
  break;
11150
11217
  default:
11151
11218
  this.eventEmitter.emit('message', message);
@@ -11176,7 +11243,7 @@ class WebSocketClient extends Emitter {
11176
11243
  this.close();
11177
11244
  }
11178
11245
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11179
- logger$7.log('Wazo WS url computed to reconnect', { url });
11246
+ logger$5.log('Wazo WS url computed to reconnect', { url });
11180
11247
 
11181
11248
  return url;
11182
11249
  }
@@ -11184,15 +11251,15 @@ class WebSocketClient extends Emitter {
11184
11251
  _onHeartbeat(message ) {
11185
11252
  if (message.payload === 'pong') {
11186
11253
  this.heartbeat.onHeartbeat();
11187
- logger$7.log('on heartbeat received from Wazo WS');
11254
+ logger$5.log('on heartbeat received from Wazo WS');
11188
11255
  }
11189
11256
  }
11190
11257
 
11191
11258
  async _onHeartbeatTimeout() {
11192
- logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
11259
+ logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
11193
11260
 
11194
11261
  this.close();
11195
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
11262
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
11196
11263
 
11197
11264
  if (this.onHeartBeatTimeout) {
11198
11265
  this.onHeartBeatTimeout();
@@ -11272,7 +11339,7 @@ WebSocketClient.eventLists = [
11272
11339
 
11273
11340
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11274
11341
  __proto__: null,
11275
- SOCKET_EVENTS: SOCKET_EVENTS,
11342
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
11276
11343
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11277
11344
  FAVORITE_ADDED: FAVORITE_ADDED,
11278
11345
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11345,10 +11412,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11345
11412
 
11346
11413
  //
11347
11414
 
11348
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11349
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11415
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11416
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11350
11417
 
11351
- const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
11418
+ const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
11352
11419
 
11353
11420
  class Websocket extends Emitter {
11354
11421
 
@@ -11362,9 +11429,9 @@ class Websocket extends Emitter {
11362
11429
  // $FlowFixMe
11363
11430
  this[key] = OTHER_EVENTS[key];
11364
11431
  });
11365
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
11432
+ Object.keys(SOCKET_EVENTS).forEach(key => {
11366
11433
  // $FlowFixMe
11367
- this[key] = SOCKET_EVENTS$1[key];
11434
+ this[key] = SOCKET_EVENTS[key];
11368
11435
  });
11369
11436
  this.eventLists = WebSocketClient.eventLists;
11370
11437
 
@@ -11372,7 +11439,7 @@ class Websocket extends Emitter {
11372
11439
  }
11373
11440
 
11374
11441
  open(host , session ) {
11375
- logger$8.info('open simple WebSocket', { host, token: session.token });
11442
+ logger$4.info('open simple WebSocket', { host, token: session.token });
11376
11443
  this.ws = new WebSocketClient(
11377
11444
  {
11378
11445
  host,
@@ -11400,7 +11467,7 @@ class Websocket extends Emitter {
11400
11467
  }
11401
11468
 
11402
11469
  updateToken(token ) {
11403
- logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
11470
+ logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
11404
11471
 
11405
11472
  if (!this.ws) {
11406
11473
  return;
@@ -11428,12 +11495,12 @@ var Websocket$1 = global.wazoWebsocketInstance;
11428
11495
 
11429
11496
  //
11430
11497
 
11431
- const logger$9 = IssueReporter$1.loggerFor('sdk-sip-room');
11498
+ const logger$3 = IssueReporter$1.loggerFor('sdk-sip-room');
11432
11499
 
11433
- class SipRoom extends Room$1 {
11500
+ class SipRoom extends Room {
11434
11501
 
11435
11502
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
11436
- logger$9.info('connecting to sip room', { extension, audioOnly, room: !!room });
11503
+ logger$3.info('connecting to sip room', { extension, audioOnly, room: !!room });
11437
11504
 
11438
11505
  if (!room) {
11439
11506
  await Wazo.Phone.connect();
@@ -11449,7 +11516,7 @@ class SipRoom extends Room$1 {
11449
11516
  room.setCallId(room.callSession.call.id);
11450
11517
  }
11451
11518
 
11452
- logger$9.info('connected to room', {
11519
+ logger$3.info('connected to room', {
11453
11520
  extension: room.extension,
11454
11521
  });
11455
11522
 
@@ -11457,7 +11524,7 @@ class SipRoom extends Room$1 {
11457
11524
  }
11458
11525
 
11459
11526
  mute() {
11460
- logger$9.info('mute sip room');
11527
+ logger$3.info('mute sip room');
11461
11528
 
11462
11529
  Wazo.Phone.mute(this.callSession, false);
11463
11530
 
@@ -11465,7 +11532,7 @@ class SipRoom extends Room$1 {
11465
11532
  }
11466
11533
 
11467
11534
  unmute() {
11468
- logger$9.info('unmute sip room');
11535
+ logger$3.info('unmute sip room');
11469
11536
 
11470
11537
  Wazo.Phone.unmute(this.callSession, false);
11471
11538
 
@@ -11567,7 +11634,7 @@ class SipRoom extends Room$1 {
11567
11634
 
11568
11635
  //
11569
11636
 
11570
- const logger$a = IssueReporter$1.loggerFor('room');
11637
+ const logger$2 = IssueReporter$1.loggerFor('room');
11571
11638
 
11572
11639
  class Participant extends Emitter {
11573
11640
 
@@ -11689,7 +11756,7 @@ class Participant extends Emitter {
11689
11756
  }
11690
11757
 
11691
11758
  onTalking(isTalking ) {
11692
- logger$a.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11759
+ logger$2.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11693
11760
  this.isTalking = isTalking;
11694
11761
  // you may notice we're not broadcasting: since all participants are getting this info
11695
11762
  // directly from asterisk, there's no need to do so
@@ -11792,7 +11859,7 @@ class Participant extends Emitter {
11792
11859
  }
11793
11860
 
11794
11861
  updateStatus(status , broadcast = true) {
11795
- logger$a.info('updating participant status', { name: this.name, status });
11862
+ logger$2.info('updating participant status', { name: this.name, status });
11796
11863
 
11797
11864
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11798
11865
  if (status.audioMuted) {
@@ -11840,7 +11907,7 @@ class Participant extends Emitter {
11840
11907
 
11841
11908
  broadcastStatus(inboundStatus = null) {
11842
11909
  const status = inboundStatus || this.getStatus();
11843
- logger$a.info('broadcasting participant status', { callId: this.callId, status });
11910
+ logger$2.info('broadcasting participant status', { callId: this.callId, status });
11844
11911
 
11845
11912
  this.room.sendSignal({
11846
11913
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -12055,7 +12122,7 @@ class NotificationOptions {
12055
12122
 
12056
12123
 
12057
12124
  // Represents a conference room, like `9000`.
12058
- class Room {
12125
+ class Room$1 {
12059
12126
 
12060
12127
 
12061
12128
 
@@ -12076,7 +12143,7 @@ class Room {
12076
12143
  }
12077
12144
 
12078
12145
  connect(callSession ) {
12079
- return new Room({ ...this, connectedCallSession: callSession });
12146
+ return new Room$1({ ...this, connectedCallSession: callSession });
12080
12147
  }
12081
12148
 
12082
12149
  has(callSession ) {
@@ -12085,7 +12152,7 @@ class Room {
12085
12152
 
12086
12153
  addParticipant(uuid , extension , talking = null) {
12087
12154
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12088
- return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12155
+ return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12089
12156
  }
12090
12157
 
12091
12158
  return this;
@@ -12104,7 +12171,7 @@ class Room {
12104
12171
  updatedParticipants.push(participant);
12105
12172
  }
12106
12173
 
12107
- return new Room({ ...this, participants: updatedParticipants });
12174
+ return new Room$1({ ...this, participants: updatedParticipants });
12108
12175
  }
12109
12176
 
12110
12177
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12120,7 +12187,7 @@ class Room {
12120
12187
  updatedParticipants.push(participant);
12121
12188
  }
12122
12189
 
12123
- return new Room({ ...this, participants: updatedParticipants });
12190
+ return new Room$1({ ...this, participants: updatedParticipants });
12124
12191
  }
12125
12192
 
12126
12193
  hasCallWithId(id ) {
@@ -12128,18 +12195,18 @@ class Room {
12128
12195
  }
12129
12196
 
12130
12197
  disconnect() {
12131
- return new Room({ ...this, connectedCallSession: null });
12198
+ return new Room$1({ ...this, connectedCallSession: null });
12132
12199
  }
12133
12200
 
12134
12201
  removeParticipantWithUUID(uuid ) {
12135
- return new Room({
12202
+ return new Room$1({
12136
12203
  ...this,
12137
12204
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12138
12205
  });
12139
12206
  }
12140
12207
 
12141
12208
  removeParticipantWithExtension(extension ) {
12142
- return new Room({
12209
+ return new Room$1({
12143
12210
  ...this,
12144
12211
  participants: this.participants.filter(participant => participant.extension !== extension),
12145
12212
  });
@@ -12150,7 +12217,7 @@ class Room {
12150
12217
  }
12151
12218
 
12152
12219
  static newFrom(room ) {
12153
- return newFrom(room, Room);
12220
+ return newFrom(room, Room$1);
12154
12221
  }
12155
12222
  }
12156
12223
 
@@ -12457,11 +12524,11 @@ var wazoWebsocket = {
12457
12524
  resolve();
12458
12525
  };
12459
12526
 
12460
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
12527
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
12461
12528
  handleError(`Connection error : ${error}`);
12462
12529
  });
12463
12530
 
12464
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
12531
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
12465
12532
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
12466
12533
  client.setOnHeartbeatTimeout(() => {
12467
12534
  handleError('No response to heartbeat');
@@ -12562,7 +12629,7 @@ var webrtc = {
12562
12629
  }),
12563
12630
  };
12564
12631
 
12565
- const parseCandidate$1 = line => {
12632
+ const parseCandidate = line => {
12566
12633
  let parts;
12567
12634
  // Parse both variants.
12568
12635
  if (line.indexOf('a=candidate:') === 0) {
@@ -12653,7 +12720,7 @@ var SymmetricNat = {
12653
12720
  }
12654
12721
 
12655
12722
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
12656
- const cand = parseCandidate$1(e.candidate.candidate);
12723
+ const cand = parseCandidate(e.candidate.candidate);
12657
12724
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
12658
12725
  candidates[cand.relatedPort].push(cand.port);
12659
12726
  } else if (!e.candidate) {
@@ -12721,7 +12788,7 @@ var iceIpv4 = {
12721
12788
  const rawCandidate = e.candidate.candidate;
12722
12789
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
12723
12790
  hasSrflxOrRelay = true;
12724
- const candidate = parseCandidate$1(e.candidate.candidate);
12791
+ const candidate = parseCandidate(e.candidate.candidate);
12725
12792
  ips.push(candidate.ip);
12726
12793
  }
12727
12794
  } else if (!e.candidate) {
@@ -12758,7 +12825,7 @@ var checks = [
12758
12825
 
12759
12826
  //
12760
12827
 
12761
- const logger$b = IssueReporter$1.loggerFor('engine-check');
12828
+ const logger$1 = IssueReporter$1.loggerFor('engine-check');
12762
12829
 
12763
12830
  class Checker {
12764
12831
 
@@ -12776,28 +12843,28 @@ class Checker {
12776
12843
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
12777
12844
  await this._addEngineVersion();
12778
12845
 
12779
- logger$b.info('Engine check starting');
12846
+ logger$1.info('Engine check starting');
12780
12847
 
12781
12848
  for (let i = 0; i < this.checks.length; i++) {
12782
12849
  const { name, check } = this.checks[i];
12783
12850
 
12784
- logger$b.info(`Checking ${name} ...`);
12851
+ logger$1.info(`Checking ${name} ...`);
12785
12852
 
12786
12853
  onCheckBegin(name);
12787
12854
  try {
12788
12855
  // eslint-disable-next-line no-await-in-loop
12789
12856
  const result = await check(this.server, this.session, this.externalAppConfig);
12790
- logger$b.info(`Checking ${name} success.`, { result });
12857
+ logger$1.info(`Checking ${name} success.`, { result });
12791
12858
 
12792
12859
  onCheckResult(name, result);
12793
12860
  } catch (e) {
12794
- logger$b.info(`Checking ${name} failure`, { message: e.message });
12861
+ logger$1.info(`Checking ${name} failure`, { message: e.message });
12795
12862
 
12796
12863
  onCheckResult(name, e);
12797
12864
  }
12798
12865
  }
12799
12866
 
12800
- logger$b.info('Engine check done.');
12867
+ logger$1.info('Engine check done.');
12801
12868
  }
12802
12869
 
12803
12870
  addCheck(check ) {
@@ -12821,7 +12888,7 @@ const Wazo = {
12821
12888
  Auth: Auth$1,
12822
12889
  Phone: Phone$1,
12823
12890
  Websocket: Websocket$1,
12824
- Room: Room$1,
12891
+ Room,
12825
12892
  SipRoom,
12826
12893
  RemoteParticipant,
12827
12894
  LocalParticipant,
@@ -12854,7 +12921,7 @@ const Wazo = {
12854
12921
  Session,
12855
12922
  Voicemail,
12856
12923
  Relocation,
12857
- ConferenceRoom: Room,
12924
+ ConferenceRoom: Room$1,
12858
12925
  CallSession,
12859
12926
  IndirectTransfer,
12860
12927
  SwitchboardCall,
@@ -12879,6 +12946,7 @@ const Wazo = {
12879
12946
  InvalidSubscription,
12880
12947
  InvalidAuthorization,
12881
12948
  CanceledCallError,
12949
+ SFUNotAvailableError,
12882
12950
  };
12883
12951
 
12884
12952
  if (window) {
@@ -12893,9 +12961,9 @@ if (global) {
12893
12961
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
12894
12962
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
12895
12963
 
12896
- const logger$c = IssueReporter$1.loggerFor('sdk-room');
12964
+ const logger = IssueReporter$1.loggerFor('sdk-room');
12897
12965
 
12898
- class Room$1 extends Emitter {
12966
+ class Room extends Emitter {
12899
12967
 
12900
12968
 
12901
12969
 
@@ -12953,7 +13021,7 @@ class Room$1 extends Emitter {
12953
13021
  extra = {},
12954
13022
  ) {
12955
13023
  super();
12956
- logger$c.info('room initialized', { callId, extension, sourceId, meetingUuid });
13024
+ logger.info('room initialized', { callId, extension, sourceId, meetingUuid });
12957
13025
 
12958
13026
  // Represents the room callSession
12959
13027
  this.callSession = callSession;
@@ -13019,7 +13087,7 @@ class Room$1 extends Emitter {
13019
13087
  * @returns {Promise<Room>}
13020
13088
  */
13021
13089
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
13022
- logger$c.info('connecting to room', { extension, audioOnly, room: !!room });
13090
+ logger.info('connecting to room', { extension, audioOnly, room: !!room });
13023
13091
 
13024
13092
  if (!room) {
13025
13093
  await Wazo.Phone.connect();
@@ -13032,7 +13100,7 @@ class Room$1 extends Emitter {
13032
13100
 
13033
13101
  // Call_created is triggered before call_accepted, so we have to listen for it here.
13034
13102
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
13035
- logger$c.info('room call received via WS', { callId: data.call_id });
13103
+ logger.info('room call received via WS', { callId: data.call_id });
13036
13104
  if (room) {
13037
13105
  room.setCallId(data.call_id);
13038
13106
  }
@@ -13040,7 +13108,7 @@ class Room$1 extends Emitter {
13040
13108
 
13041
13109
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
13042
13110
  // eslint-disable-next-line no-param-reassign
13043
- room = new Room$1(callSession, extension, null, null, extra);
13111
+ room = new Room(callSession, extension, null, null, extra);
13044
13112
 
13045
13113
  // Wait for the call to be accepted
13046
13114
  await new Promise((resolve, reject) => {
@@ -13061,7 +13129,7 @@ class Room$1 extends Emitter {
13061
13129
  // Retrieve conference
13062
13130
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
13063
13131
 
13064
- logger$c.info('connected to room', {
13132
+ logger.info('connected to room', {
13065
13133
  sourceId: conference ? conference.sourceId : null,
13066
13134
  name: conference ? conference.name : null,
13067
13135
  });
@@ -13071,7 +13139,7 @@ class Room$1 extends Emitter {
13071
13139
  room.setName(conference.name);
13072
13140
  }
13073
13141
  } else if (meeting) {
13074
- logger$c.info('Already connected to meeting', {
13142
+ logger.info('Already connected to meeting', {
13075
13143
  uuid: meeting.uuid,
13076
13144
  name: meeting.name,
13077
13145
  });
@@ -13084,13 +13152,13 @@ class Room$1 extends Emitter {
13084
13152
  }
13085
13153
 
13086
13154
  static disconnect() {
13087
- logger$c.info('static disconnection to room');
13155
+ logger.info('static disconnection to room');
13088
13156
 
13089
13157
  Wazo.Phone.disconnect();
13090
13158
  }
13091
13159
 
13092
13160
  async disconnect() {
13093
- logger$c.info('disconnection to room called');
13161
+ logger.info('disconnection to room called');
13094
13162
 
13095
13163
  await Wazo.Phone.hangup(this.callSession);
13096
13164
  this.callSession = null;
@@ -13110,19 +13178,19 @@ class Room$1 extends Emitter {
13110
13178
  }
13111
13179
 
13112
13180
  setSourceId(sourceId ) {
13113
- logger$c.info('set room source id', { sourceId });
13181
+ logger.info('set room source id', { sourceId });
13114
13182
 
13115
13183
  this.sourceId = sourceId;
13116
13184
  }
13117
13185
 
13118
13186
  setMeetingUuid(meetingUuid ) {
13119
- logger$c.info('set meeting uuid', { meetingUuid });
13187
+ logger.info('set meeting uuid', { meetingUuid });
13120
13188
 
13121
13189
  this.meetingUuid = meetingUuid;
13122
13190
  }
13123
13191
 
13124
13192
  setCallId(callId ) {
13125
- logger$c.info('set room call id', { callId });
13193
+ logger.info('set room call id', { callId });
13126
13194
 
13127
13195
  if (callId) {
13128
13196
  this.callId = callId;
@@ -13130,7 +13198,7 @@ class Room$1 extends Emitter {
13130
13198
  }
13131
13199
 
13132
13200
  setName(name ) {
13133
- logger$c.info('set room name', { name });
13201
+ logger.info('set room name', { name });
13134
13202
 
13135
13203
  this.name = name;
13136
13204
  }
@@ -13149,7 +13217,7 @@ class Room$1 extends Emitter {
13149
13217
  }
13150
13218
 
13151
13219
  async startScreenSharing(constraints ) {
13152
- logger$c.info('start room screen sharing', { constraints });
13220
+ logger.info('start room screen sharing', { constraints });
13153
13221
 
13154
13222
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
13155
13223
  if (!screensharingStream) {
@@ -13163,7 +13231,7 @@ class Room$1 extends Emitter {
13163
13231
  }
13164
13232
 
13165
13233
  async stopScreenSharing(restoreLocalStream = true) {
13166
- logger$c.info('stop room screen sharing');
13234
+ logger.info('stop room screen sharing');
13167
13235
 
13168
13236
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
13169
13237
 
@@ -13175,7 +13243,7 @@ class Room$1 extends Emitter {
13175
13243
  }
13176
13244
 
13177
13245
  turnCameraOff() {
13178
- logger$c.info('turn room camera off');
13246
+ logger.info('turn room camera off');
13179
13247
 
13180
13248
  Wazo.Phone.turnCameraOff(this.callSession);
13181
13249
 
@@ -13185,7 +13253,7 @@ class Room$1 extends Emitter {
13185
13253
  }
13186
13254
 
13187
13255
  turnCameraOn() {
13188
- logger$c.info('turn room camera on');
13256
+ logger.info('turn room camera on');
13189
13257
 
13190
13258
  Wazo.Phone.turnCameraOn(this.callSession);
13191
13259
 
@@ -13195,7 +13263,7 @@ class Room$1 extends Emitter {
13195
13263
  }
13196
13264
 
13197
13265
  mute() {
13198
- logger$c.info('mute room');
13266
+ logger.info('mute room');
13199
13267
 
13200
13268
  Wazo.Phone.mute(this.callSession);
13201
13269
 
@@ -13203,7 +13271,7 @@ class Room$1 extends Emitter {
13203
13271
  }
13204
13272
 
13205
13273
  unmute() {
13206
- logger$c.info('unmute room');
13274
+ logger.info('unmute room');
13207
13275
 
13208
13276
  Wazo.Phone.unmute(this.callSession);
13209
13277
 
@@ -13223,7 +13291,7 @@ class Room$1 extends Emitter {
13223
13291
  }
13224
13292
 
13225
13293
  hold() {
13226
- logger$c.info('hold room');
13294
+ logger.info('hold room');
13227
13295
 
13228
13296
  Wazo.Phone.hold(this.callSession, true);
13229
13297
 
@@ -13233,7 +13301,7 @@ class Room$1 extends Emitter {
13233
13301
  }
13234
13302
 
13235
13303
  async resume() {
13236
- logger$c.info('resume room');
13304
+ logger.info('resume room');
13237
13305
 
13238
13306
  const newStream = await Wazo.Phone.resume(this.callSession, true);
13239
13307
 
@@ -13261,13 +13329,13 @@ class Room$1 extends Emitter {
13261
13329
  }
13262
13330
 
13263
13331
  sendDTMF(tone ) {
13264
- logger$c.info('send room DTMF', { tone });
13332
+ logger.info('send room DTMF', { tone });
13265
13333
 
13266
13334
  Wazo.Phone.sendDTMF(tone, this.callSession);
13267
13335
  }
13268
13336
 
13269
13337
  async sendReinvite(newConstraints = null) {
13270
- logger$c.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13338
+ logger.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
13271
13339
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
13272
13340
 
13273
13341
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -13326,7 +13394,7 @@ class Room$1 extends Emitter {
13326
13394
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
13327
13395
 
13328
13396
  this.on(this.ON_AUDIO_STREAM, stream => {
13329
- logger$c.info('on room audio stream');
13397
+ logger.info('on room audio stream');
13330
13398
 
13331
13399
  this.audioStream = stream;
13332
13400
  if (!this.roomAudioElement) {
@@ -13339,7 +13407,7 @@ class Room$1 extends Emitter {
13339
13407
  });
13340
13408
 
13341
13409
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
13342
- logger$c.info('on room video stream', { streamId });
13410
+ logger.info('on room video stream', { streamId });
13343
13411
 
13344
13412
  this._mapMsid(sipSession.body.body);
13345
13413
 
@@ -13354,7 +13422,7 @@ class Room$1 extends Emitter {
13354
13422
  });
13355
13423
 
13356
13424
  this.on(this.ON_REMOVE_STREAM, stream => {
13357
- logger$c.info('on room remove stream');
13425
+ logger.info('on room remove stream');
13358
13426
 
13359
13427
  const participant = this.participants.find(someParticipant =>
13360
13428
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -13486,7 +13554,7 @@ class Room$1 extends Emitter {
13486
13554
  const requester = this._getParticipantFromCallId(origin.callId);
13487
13555
  if (requester) {
13488
13556
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
13489
- logger$c.info('trigger room requester status', { origin });
13557
+ logger.info('trigger room requester status', { origin });
13490
13558
  requester.triggerUpdate('REQUESTER_UPDATE');
13491
13559
  }
13492
13560
  break;
@@ -13517,24 +13585,24 @@ class Room$1 extends Emitter {
13517
13585
 
13518
13586
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
13519
13587
  if (participant.user_uuid === session.uuid) {
13520
- logger$c.info('room current user joined');
13588
+ logger.info('room current user joined');
13521
13589
 
13522
13590
  // Retrieve participants via an API calls
13523
13591
  const conferenceId = this.sourceId || payload.data.conference_id;
13524
13592
  let response;
13525
13593
  try {
13526
13594
  if (this.meetingUuid) {
13527
- logger$c.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13595
+ logger.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
13528
13596
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
13529
13597
  } else {
13530
- logger$c.info('fetching conference participants', { conferenceId });
13598
+ logger.info('fetching conference participants', { conferenceId });
13531
13599
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
13532
13600
  }
13533
13601
  } catch (e) {
13534
- logger$c.error('room participants fetching, error', e);
13602
+ logger.error('room participants fetching, error', e);
13535
13603
  }
13536
13604
  if (response) {
13537
- logger$c.info('conference participants fetched', { nb: response.items.length });
13605
+ logger.info('conference participants fetched', { nb: response.items.length });
13538
13606
  participants = response.items.map(item => {
13539
13607
  const isMe = item.call_id === this.callId;
13540
13608
 
@@ -13561,7 +13629,7 @@ class Room$1 extends Emitter {
13561
13629
  ? new Wazo.RemoteParticipant(this, participant)
13562
13630
  : null;
13563
13631
 
13564
- logger$c.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13632
+ logger.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
13565
13633
 
13566
13634
  if (remoteParticipant) {
13567
13635
  this.participants.push(remoteParticipant);
@@ -13724,5 +13792,5 @@ class Room$1 extends Emitter {
13724
13792
  }
13725
13793
  }
13726
13794
 
13727
- export default Room$1;
13795
+ export default Room;
13728
13796
  export { SIGNAL_TYPE_PARTICIPANT_REQUEST, SIGNAL_TYPE_PARTICIPANT_UPDATE };