@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
@@ -1248,7 +1248,7 @@ class Contact {
1248
1248
  this[key] = old[key] || this[key];
1249
1249
  });
1250
1250
 
1251
- if (old.lineState && !this.lineState) {
1251
+ if (old.lineState) {
1252
1252
  this.lineState = old.lineState;
1253
1253
  }
1254
1254
 
@@ -1959,11 +1959,11 @@ var IssueReporter$1 = new IssueReporter();
1959
1959
 
1960
1960
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1961
1961
 
1962
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1962
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1963
1963
 
1964
1964
  // Use a function here to be able to mock it in tests
1965
1965
  const realFetch = () => {
1966
- if (typeof document !== 'undefined') {
1966
+ if (typeof document !== 'undefined' && window.fetch) {
1967
1967
  // Browser
1968
1968
  return window.fetch;
1969
1969
  }
@@ -2098,7 +2098,7 @@ class ApiRequester {
2098
2098
  };
2099
2099
 
2100
2100
  if (this.refreshTokenPromise) {
2101
- logger.info('A token is already refreshing, waiting ...', { url });
2101
+ logger$c.info('A token is already refreshing, waiting ...', { url });
2102
2102
  await this.refreshTokenPromise;
2103
2103
  }
2104
2104
 
@@ -2118,7 +2118,7 @@ class ApiRequester {
2118
2118
  return promise.then(async (err ) => {
2119
2119
  // Check if the token is still valid
2120
2120
  if (firstCall && this._checkTokenExpired(response, err)) {
2121
- logger.warn('token expired', { error: err.reason });
2121
+ logger$c.warn('token expired', { error: err.reason });
2122
2122
  // Replay the call after refreshing the token
2123
2123
  return this._replayWithNewToken(err, path, method, body, headers, parse);
2124
2124
  }
@@ -2128,7 +2128,7 @@ class ApiRequester {
2128
2128
  : exceptionClass.fromResponse(err, response.status);
2129
2129
 
2130
2130
  if (this.shouldLogErrors) {
2131
- logger.error('API error', error);
2131
+ logger$c.error('API error', error);
2132
2132
  }
2133
2133
 
2134
2134
  throw error;
@@ -2138,7 +2138,7 @@ class ApiRequester {
2138
2138
  return newParse(response, isJson);
2139
2139
  }).catch(error => {
2140
2140
  if (this.shouldLogErrors) {
2141
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2141
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2142
2142
  }
2143
2143
 
2144
2144
  throw error;
@@ -2166,13 +2166,13 @@ class ApiRequester {
2166
2166
  ) {
2167
2167
  const isTokenNotFound = this._isTokenNotFound(err);
2168
2168
  let newPath = path;
2169
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2169
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2170
2170
 
2171
2171
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
2172
2172
 
2173
2173
  return this.refreshTokenPromise.then(() => {
2174
2174
  this.refreshTokenPromise = null;
2175
- logger.info('token refreshed', { isTokenNotFound });
2175
+ logger$c.info('token refreshed', { isTokenNotFound });
2176
2176
  if (isTokenNotFound) {
2177
2177
  const pathParts = path.split('/');
2178
2178
  pathParts.pop();
@@ -3265,8 +3265,10 @@ var updateFrom = (instance , from ) => {
3265
3265
 
3266
3266
 
3267
3267
 
3268
+
3268
3269
 
3269
3270
 
3271
+
3270
3272
 
3271
3273
 
3272
3274
 
@@ -3283,6 +3285,7 @@ var updateFrom = (instance , from ) => {
3283
3285
 
3284
3286
 
3285
3287
 
3288
+
3286
3289
 
3287
3290
 
3288
3291
  class CallSession {
@@ -3302,8 +3305,12 @@ class CallSession {
3302
3305
 
3303
3306
 
3304
3307
 
3308
+
3309
+
3305
3310
 
3306
3311
 
3312
+
3313
+
3307
3314
 
3308
3315
 
3309
3316
 
@@ -3341,6 +3348,8 @@ class CallSession {
3341
3348
 
3342
3349
 
3343
3350
 
3351
+
3352
+
3344
3353
 
3345
3354
  constructor({
3346
3355
  answered,
@@ -3354,6 +3363,8 @@ class CallSession {
3354
3363
  paused,
3355
3364
  ringing,
3356
3365
  startTime,
3366
+ creationTime,
3367
+ endTime,
3357
3368
  cameraEnabled,
3358
3369
  dialedExtension,
3359
3370
  sipCallId,
@@ -3366,12 +3377,15 @@ class CallSession {
3366
3377
  recording,
3367
3378
  recordingPaused,
3368
3379
  videoRemotelyDowngraded,
3380
+ sipSession,
3369
3381
  } ) {
3370
3382
  this.callId = callId;
3371
3383
  this.sipCallId = sipCallId;
3372
3384
  this.displayName = displayName;
3373
3385
  this.number = number;
3386
+ this.creationTime = creationTime;
3374
3387
  this.startTime = startTime;
3388
+ this.endTime = endTime;
3375
3389
  this.isCaller = isCaller;
3376
3390
  this.answered = answered;
3377
3391
  this.answeredBySystem = answeredBySystem;
@@ -3390,6 +3404,7 @@ class CallSession {
3390
3404
  this.recording = recording || false;
3391
3405
  this.recordingPaused = recordingPaused || false;
3392
3406
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3407
+ this.sipSession = sipSession;
3393
3408
 
3394
3409
  // Useful to compare instead of instanceof with minified code
3395
3410
  this.type = 'CallSession';
@@ -4065,7 +4080,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4065
4080
 
4066
4081
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4067
4082
 
4068
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4083
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4069
4084
 
4070
4085
  class CTIPhone extends Emitter {
4071
4086
 
@@ -4078,7 +4093,7 @@ class CTIPhone extends Emitter {
4078
4093
 
4079
4094
  constructor(session , isMobile = false, callbackAllLines = false) {
4080
4095
  super();
4081
- logger$1.info('CTI Phone created');
4096
+ logger$b.info('CTI Phone created');
4082
4097
  this.session = session;
4083
4098
  this.isMobile = isMobile;
4084
4099
  this.callbackAllLines = callbackAllLines;
@@ -4139,7 +4154,7 @@ class CTIPhone extends Emitter {
4139
4154
  }
4140
4155
 
4141
4156
  async makeCall(number , line ) {
4142
- logger$1.info('make CTI call', { number });
4157
+ logger$b.info('make CTI call', { number });
4143
4158
 
4144
4159
  if (!number) {
4145
4160
  return null;
@@ -4162,7 +4177,7 @@ class CTIPhone extends Emitter {
4162
4177
  if (!callSession) {
4163
4178
  return Promise.resolve(null);
4164
4179
  }
4165
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4180
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4166
4181
 
4167
4182
  if (!this.currentCall) {
4168
4183
  this.currentCall = callSession.call;
@@ -4175,7 +4190,7 @@ class CTIPhone extends Emitter {
4175
4190
  if (!callSession) {
4176
4191
  return;
4177
4192
  }
4178
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4193
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4179
4194
 
4180
4195
  this.currentCall = undefined;
4181
4196
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4185,7 +4200,7 @@ class CTIPhone extends Emitter {
4185
4200
  if (!callSession) {
4186
4201
  return Promise.resolve(false);
4187
4202
  }
4188
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4203
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4189
4204
 
4190
4205
  try {
4191
4206
  await CallApi.cancelCall(callSession);
@@ -4196,7 +4211,7 @@ class CTIPhone extends Emitter {
4196
4211
  this.eventEmitter.emit('onCallEnded', callSession);
4197
4212
  return true;
4198
4213
  } catch (e) {
4199
- logger$1.error('hangup CTI call, error', e);
4214
+ logger$b.error('hangup CTI call, error', e);
4200
4215
 
4201
4216
  this.eventEmitter.emit('onCallFailed', callSession);
4202
4217
  return false;
@@ -4209,7 +4224,7 @@ class CTIPhone extends Emitter {
4209
4224
  if (!callSession) {
4210
4225
  return;
4211
4226
  }
4212
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4227
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4213
4228
 
4214
4229
  await CallApi.cancelCall(callSession);
4215
4230
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4219,7 +4234,7 @@ class CTIPhone extends Emitter {
4219
4234
  if (!callSession) {
4220
4235
  return;
4221
4236
  }
4222
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4237
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4223
4238
 
4224
4239
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4225
4240
  }
@@ -4232,19 +4247,19 @@ class CTIPhone extends Emitter {
4232
4247
  if (!callSession) {
4233
4248
  return;
4234
4249
  }
4235
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4250
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4236
4251
 
4237
4252
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4238
4253
  }
4239
4254
 
4240
4255
  async cancelCTIIndirectTransfer(transferId ) {
4241
- logger$1.info('cancel CTI transfer', { transferId });
4256
+ logger$b.info('cancel CTI transfer', { transferId });
4242
4257
 
4243
4258
  return CallApi.cancelCallTransfer(transferId);
4244
4259
  }
4245
4260
 
4246
4261
  async confirmCTIIndirectTransfer(transferId ) {
4247
- logger$1.info('confirm CTI transfer', { transferId });
4262
+ logger$b.info('confirm CTI transfer', { transferId });
4248
4263
 
4249
4264
  return CallApi.confirmCallTransfer(transferId);
4250
4265
  }
@@ -4253,19 +4268,19 @@ class CTIPhone extends Emitter {
4253
4268
  if (!callSession) {
4254
4269
  return;
4255
4270
  }
4256
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4271
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4257
4272
 
4258
4273
  return CallApi.sendDTMF(callSession.callId, digits);
4259
4274
  }
4260
4275
 
4261
4276
  onConnectionMade() {
4262
- logger$1.info('on CTI connection made');
4277
+ logger$b.info('on CTI connection made');
4263
4278
 
4264
4279
  this.eventEmitter.emit('onCallAccepted');
4265
4280
  }
4266
4281
 
4267
4282
  async close() {
4268
- logger$1.info('CTI close');
4283
+ logger$b.info('CTI close');
4269
4284
 
4270
4285
  return Promise.resolve();
4271
4286
  }
@@ -4274,7 +4289,7 @@ class CTIPhone extends Emitter {
4274
4289
  if (!callSession) {
4275
4290
  return;
4276
4291
  }
4277
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4292
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4278
4293
 
4279
4294
  return CallApi.hold(callSession.callId);
4280
4295
  }
@@ -4283,7 +4298,7 @@ class CTIPhone extends Emitter {
4283
4298
  if (!callSession) {
4284
4299
  return;
4285
4300
  }
4286
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4301
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4287
4302
 
4288
4303
  return CallApi.resume(callSession.callId);
4289
4304
  }
@@ -4292,7 +4307,7 @@ class CTIPhone extends Emitter {
4292
4307
  if (!callSession) {
4293
4308
  return;
4294
4309
  }
4295
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4310
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4296
4311
 
4297
4312
  return CallApi.mute(callSession.callId);
4298
4313
  }
@@ -4301,7 +4316,7 @@ class CTIPhone extends Emitter {
4301
4316
  if (!callSession) {
4302
4317
  return;
4303
4318
  }
4304
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4319
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4305
4320
 
4306
4321
  return CallApi.unmute(callSession.callId);
4307
4322
  }
@@ -5310,7 +5325,7 @@ const AGENTD_VERSION = '1.0';
5310
5325
  const WEBHOOKD_VERSION = '1.0';
5311
5326
  const AMID_VERSION = '1.0';
5312
5327
 
5313
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5328
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5314
5329
 
5315
5330
  class ApiClient {
5316
5331
 
@@ -5362,12 +5377,12 @@ class ApiClient {
5362
5377
  }
5363
5378
 
5364
5379
  async forceRefreshToken() {
5365
- logger$2.info('forcing refresh token, calling callback');
5380
+ logger$a.info('forcing refresh token, calling callback');
5366
5381
  return this.refreshTokenCallback();
5367
5382
  }
5368
5383
 
5369
5384
  async refreshTokenCallback() {
5370
- logger$2.info('refresh token callback called', {
5385
+ logger$a.info('refresh token callback called', {
5371
5386
  refreshToken: this.refreshToken,
5372
5387
  refreshBackend: this.refreshBackend,
5373
5388
  refreshExpiration: this.refreshExpiration,
@@ -5385,7 +5400,7 @@ class ApiClient {
5385
5400
  this.isMobile,
5386
5401
  );
5387
5402
 
5388
- logger$2.info('token refreshed', { token: session.token });
5403
+ logger$a.info('token refreshed', { token: session.token });
5389
5404
 
5390
5405
  if (this.onRefreshToken) {
5391
5406
  this.onRefreshToken(session.token, session);
@@ -5526,7 +5541,7 @@ var getApiClient = (forServer ) => {
5526
5541
  class InvalidSubscription extends Error {}
5527
5542
  class InvalidAuthorization extends Error {}
5528
5543
 
5529
- const logger$3 = IssueReporter$1.loggerFor('simple-auth');
5544
+ const logger$9 = IssueReporter$1.loggerFor('simple-auth');
5530
5545
 
5531
5546
  class Auth {
5532
5547
 
@@ -5561,7 +5576,7 @@ class Auth {
5561
5576
  setApiClientId(this.clientId);
5562
5577
  setRefreshExpiration(this.expiration);
5563
5578
  setOnRefreshToken((token , session ) => {
5564
- logger$3.info('on refresh token done', { token });
5579
+ logger$9.info('on refresh token done', { token });
5565
5580
  setApiToken(token);
5566
5581
  Wazo.Websocket.updateToken(token);
5567
5582
 
@@ -5606,7 +5621,7 @@ class Auth {
5606
5621
  const rawSession = await getApiClient().auth.authenticate(token);
5607
5622
  return this._onAuthenticated(rawSession);
5608
5623
  } catch (e) {
5609
- logger$3.error('on validate token error', e);
5624
+ logger$9.error('on validate token error', e);
5610
5625
  console.warn(e);
5611
5626
  return false;
5612
5627
  }
@@ -5962,7 +5977,7 @@ class AdHocAPIConference {
5962
5977
 
5963
5978
  /* */
5964
5979
 
5965
- const parseCandidate = (candidate ) => {
5980
+ const parseCandidate$1 = (candidate ) => {
5966
5981
  if (!candidate) {
5967
5982
  return null;
5968
5983
  }
@@ -6074,11 +6089,16 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6074
6089
 
6075
6090
  // $FlowFixMe
6076
6091
  setRemoteSessionDescription(sessionDescription ) {
6077
- const result = super.setRemoteSessionDescription(sessionDescription);
6092
+ try {
6093
+ const result = super.setRemoteSessionDescription(sessionDescription);
6078
6094
 
6079
- this.eventEmitter.emit('setDescription', sessionDescription);
6095
+ this.eventEmitter.emit('setDescription', sessionDescription);
6080
6096
 
6081
- return result;
6097
+ return result;
6098
+ } catch (error) {
6099
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
6100
+ throw error;
6101
+ }
6082
6102
  }
6083
6103
 
6084
6104
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -6116,7 +6136,7 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6116
6136
  this.peerConnectionDelegate.onicecandidate = event => {
6117
6137
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6118
6138
  if (event.candidate) {
6119
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
6139
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6120
6140
  }
6121
6141
  };
6122
6142
 
@@ -6580,7 +6600,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6580
6600
  const SEND_STATS_DELAY = 5000;
6581
6601
 
6582
6602
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6583
- const logger$4 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6603
+ const logger$8 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6584
6604
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6585
6605
 
6586
6606
  // events
@@ -6594,14 +6614,14 @@ const TRANSPORT_ERROR = 'transportError';
6594
6614
  const MESSAGE = 'message';
6595
6615
  const ACCEPTED = 'accepted';
6596
6616
  const REJECTED = 'rejected';
6597
- const ON_TRACK = 'onTrack';
6598
- const ON_REINVITE = 'reinvite';
6617
+ const ON_TRACK$1 = 'onTrack';
6618
+ const ON_REINVITE$1 = 'reinvite';
6599
6619
  const ON_ERROR = 'onError';
6600
6620
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6601
- const ON_NETWORK_STATS = 'onNetworkStats';
6602
- const ON_DISCONNECTED = 'onDisconnected';
6621
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6622
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6603
6623
 
6604
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6624
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6605
6625
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6606
6626
  class CanceledCallError extends Error {}
6607
6627
 
@@ -6737,12 +6757,12 @@ class WebRTCClient extends Emitter {
6737
6757
  this.MESSAGE = MESSAGE;
6738
6758
  this.ACCEPTED = ACCEPTED;
6739
6759
  this.REJECTED = REJECTED;
6740
- this.ON_TRACK = ON_TRACK;
6741
- this.ON_REINVITE = ON_REINVITE;
6760
+ this.ON_TRACK = ON_TRACK$1;
6761
+ this.ON_REINVITE = ON_REINVITE$1;
6742
6762
  this.ON_ERROR = ON_ERROR;
6743
6763
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6744
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6745
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6764
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6765
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6746
6766
  }
6747
6767
 
6748
6768
  configureMedia(media ) {
@@ -6759,13 +6779,13 @@ class WebRTCClient extends Emitter {
6759
6779
 
6760
6780
  createUserAgent(configOverrides ) {
6761
6781
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6762
- logger$4.info('sdk webrtc, creating UA', { webRTCConfiguration });
6782
+ logger$8.info('sdk webrtc, creating UA', { webRTCConfiguration });
6763
6783
 
6764
6784
  webRTCConfiguration.delegate = {
6765
6785
  onConnect: this.onConnect.bind(this),
6766
6786
  onDisconnect: this.onDisconnect.bind(this),
6767
6787
  onInvite: (invitation ) => {
6768
- logger$4.info('sdk webrtc on invite', {
6788
+ logger$8.info('sdk webrtc on invite', {
6769
6789
  method: 'delegate.onInvite',
6770
6790
  id: invitation.id,
6771
6791
  remoteURI: invitation.remoteURI,
@@ -6808,7 +6828,7 @@ class WebRTCClient extends Emitter {
6808
6828
  }
6809
6829
 
6810
6830
  onConnect() {
6811
- logger$4.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6831
+ logger$8.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6812
6832
  this.eventEmitter.emit(CONNECTED);
6813
6833
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6814
6834
  this.registerer.waitingToggle(false);
@@ -6817,7 +6837,7 @@ class WebRTCClient extends Emitter {
6817
6837
  }
6818
6838
 
6819
6839
  async onDisconnect(error ) {
6820
- logger$4.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6840
+ logger$8.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6821
6841
  this.connectionPromise = null;
6822
6842
  // The UA will attempt to reconnect automatically when an error occurred
6823
6843
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6842,37 +6862,37 @@ class WebRTCClient extends Emitter {
6842
6862
  };
6843
6863
 
6844
6864
  if (this.skipRegister) {
6845
- logger$4.info('sdk webrtc skip register...', logInfo);
6865
+ logger$8.info('sdk webrtc skip register...', logInfo);
6846
6866
  return Promise.resolve();
6847
6867
  }
6848
6868
 
6849
- logger$4.info('sdk webrtc registering...', logInfo);
6869
+ logger$8.info('sdk webrtc registering...', logInfo);
6850
6870
 
6851
6871
  if (!this.userAgent) {
6852
- logger$4.info('sdk webrtc recreating User Agent');
6872
+ logger$8.info('sdk webrtc recreating User Agent');
6853
6873
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6854
6874
  }
6855
6875
  if (!this.userAgent || this.isRegistered()) {
6856
- logger$4.info('sdk webrtc registering aborted, already registered or no UA can be created');
6876
+ logger$8.info('sdk webrtc registering aborted, already registered or no UA can be created');
6857
6877
  return Promise.resolve();
6858
6878
  }
6859
6879
 
6860
6880
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6861
- logger$4.info('sdk webrtc registering aborted due to a registration in progress.');
6881
+ logger$8.info('sdk webrtc registering aborted due to a registration in progress.');
6862
6882
  return Promise.resolve();
6863
6883
  }
6864
6884
 
6865
6885
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6866
6886
 
6867
6887
  const onRegisterFailed = () => {
6868
- logger$4.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6888
+ logger$8.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6869
6889
  this.connectionPromise = null;
6870
6890
  if (this.registerer && this.registerer.waiting) {
6871
6891
  this.registerer.waitingToggle(false);
6872
6892
  }
6873
6893
 
6874
6894
  if (tries <= MAX_REGISTER_TRIES) {
6875
- logger$4.info('sdk webrtc registering, retrying...', { tries });
6895
+ logger$8.info('sdk webrtc registering, retrying...', { tries });
6876
6896
  setTimeout(() => this.register(tries + 1), 300);
6877
6897
  }
6878
6898
  };
@@ -6881,18 +6901,18 @@ class WebRTCClient extends Emitter {
6881
6901
  // Avoid race condition with the close method called just before register and setting userAgent to null
6882
6902
  // during the resolution of the primise.
6883
6903
  if (!this.userAgent) {
6884
- logger$4.info('sdk webrtc recreating User Agent after connection');
6904
+ logger$8.info('sdk webrtc recreating User Agent after connection');
6885
6905
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6886
6906
  }
6887
6907
 
6888
- logger$4.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6908
+ logger$8.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6889
6909
  this.registerer = new registerer.Registerer(this.userAgent, registerOptions);
6890
6910
  this.connectionPromise = null;
6891
6911
  this._monkeyPatchRegisterer(this.registerer);
6892
6912
 
6893
6913
  // Bind registerer events
6894
6914
  this.registerer.stateChange.addListener(newState => {
6895
- logger$4.info('sdk webrtc registering, state changed', { newState });
6915
+ logger$8.info('sdk webrtc registering, state changed', { newState });
6896
6916
 
6897
6917
  if (newState === registererState.RegistererState.Registered && this.registerer
6898
6918
  && this.registerer.state === registererState.RegistererState.Registered) {
@@ -6905,7 +6925,7 @@ class WebRTCClient extends Emitter {
6905
6925
  const options = {
6906
6926
  requestDelegate: {
6907
6927
  onReject: response => {
6908
- logger$4.error('sdk webrtc registering, rejected', { response });
6928
+ logger$8.error('sdk webrtc registering, rejected', { response });
6909
6929
 
6910
6930
  onRegisterFailed();
6911
6931
  },
@@ -6913,13 +6933,13 @@ class WebRTCClient extends Emitter {
6913
6933
  };
6914
6934
 
6915
6935
  return this.registerer.register(options).catch((e) => {
6916
- logger$4.error('sdk webrtc registering, error', e);
6936
+ logger$8.error('sdk webrtc registering, error', e);
6917
6937
 
6918
6938
  this.eventEmitter.emit(REGISTRATION_FAILED);
6919
6939
  return e;
6920
6940
  });
6921
6941
  }).catch(error => {
6922
- logger$4.error('sdk webrtc registering, transport error', error);
6942
+ logger$8.error('sdk webrtc registering, transport error', error);
6923
6943
  onRegisterFailed();
6924
6944
  });
6925
6945
  }
@@ -6948,21 +6968,21 @@ class WebRTCClient extends Emitter {
6948
6968
  }
6949
6969
 
6950
6970
  unregister() {
6951
- logger$4.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6971
+ logger$8.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6952
6972
  if (!this.registerer) {
6953
6973
  return Promise.resolve();
6954
6974
  }
6955
6975
 
6956
6976
  try {
6957
6977
  return this.registerer.unregister().then(() => {
6958
- logger$4.info('sdk webrtc unregistered');
6978
+ logger$8.info('sdk webrtc unregistered');
6959
6979
  this._cleanupRegister();
6960
6980
  }).catch(e => {
6961
- logger$4.error('sdk webrtc unregistering, promise error', e);
6981
+ logger$8.error('sdk webrtc unregistering, promise error', e);
6962
6982
  this._cleanupRegister();
6963
6983
  });
6964
6984
  } catch (e) {
6965
- logger$4.error('sdk webrtc unregistering, error', e);
6985
+ logger$8.error('sdk webrtc unregistering, error', e);
6966
6986
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6967
6987
  // error when the registerer is in a bad state
6968
6988
  this._cleanupRegister();
@@ -6970,7 +6990,7 @@ class WebRTCClient extends Emitter {
6970
6990
  }
6971
6991
 
6972
6992
  stop() {
6973
- logger$4.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6993
+ logger$8.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6974
6994
  if (!this.userAgent) {
6975
6995
  return Promise.resolve();
6976
6996
  }
@@ -6978,12 +6998,12 @@ class WebRTCClient extends Emitter {
6978
6998
  return this.userAgent.stop().then(() => {
6979
6999
  return this._cleanupRegister();
6980
7000
  }).catch(e => {
6981
- logger$4.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
7001
+ logger$8.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6982
7002
  });
6983
7003
  }
6984
7004
 
6985
7005
  call(number , enableVideo , audioOnly = false, conference = false) {
6986
- logger$4.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
7006
+ logger$8.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6987
7007
  const inviterOptions = {
6988
7008
  sessionDescriptionHandlerOptionsReInvite: {
6989
7009
  conference,
@@ -7014,7 +7034,7 @@ class WebRTCClient extends Emitter {
7014
7034
  this._onAccepted(session, response.session, true);
7015
7035
  },
7016
7036
  onReject: (response ) => {
7017
- logger$4.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7037
+ logger$8.info('on call rejected', { id: session.id, fromTag: session.fromTag });
7018
7038
  this._stopSendingStats(session);
7019
7039
  this.stopNetworkMonitoring(session);
7020
7040
 
@@ -7037,11 +7057,11 @@ class WebRTCClient extends Emitter {
7037
7057
  }
7038
7058
 
7039
7059
  answer(session , enableVideo ) {
7040
- logger$4.info('sdk webrtc answer call', { id: session.id, enableVideo });
7060
+ logger$8.info('sdk webrtc answer call', { id: session.id, enableVideo });
7041
7061
 
7042
7062
  if (!session || !session.accept) {
7043
7063
  const error = 'No session to answer, or not an invitation';
7044
- logger$4.warn(error);
7064
+ logger$8.warn(error);
7045
7065
  return Promise.reject(new Error(error));
7046
7066
  }
7047
7067
  const options = {
@@ -7051,15 +7071,15 @@ class WebRTCClient extends Emitter {
7051
7071
  return session.accept(options).then(() => {
7052
7072
  if (session.isCanceled) {
7053
7073
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
7054
- logger$4.error(message, { id: session.id });
7074
+ logger$8.error(message, { id: session.id });
7055
7075
  this.onCallEnded(session);
7056
7076
 
7057
7077
  throw new CanceledCallError(message);
7058
7078
  }
7059
- logger$4.info('sdk webrtc answer, accepted.');
7079
+ logger$8.info('sdk webrtc answer, accepted.');
7060
7080
  this._onAccepted(session);
7061
7081
  }).catch(e => {
7062
- logger$4.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7082
+ logger$8.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
7063
7083
 
7064
7084
  throw e;
7065
7085
  });
@@ -7067,7 +7087,7 @@ class WebRTCClient extends Emitter {
7067
7087
 
7068
7088
  hangup(session ) {
7069
7089
  const { state, id } = session;
7070
- logger$4.info('sdk webrtc hangup call', { id, state });
7090
+ logger$8.info('sdk webrtc hangup call', { id, state });
7071
7091
 
7072
7092
  try {
7073
7093
  this._stopSendingStats(session);
@@ -7096,7 +7116,7 @@ class WebRTCClient extends Emitter {
7096
7116
 
7097
7117
  return bye();
7098
7118
  } catch (error) {
7099
- logger$4.warn('sdk webrtc hangup, error', error);
7119
+ logger$8.warn('sdk webrtc hangup, error', error);
7100
7120
  }
7101
7121
 
7102
7122
  return null;
@@ -7114,7 +7134,7 @@ class WebRTCClient extends Emitter {
7114
7134
  // Fetch and emit an event at `interval` with session network stats
7115
7135
  startNetworkMonitoring(session , interval = 1000) {
7116
7136
  const sessionId = this.getSipSessionId(session);
7117
- logger$4.info('starting network inspection', { id: sessionId });
7137
+ logger$8.info('starting network inspection', { id: sessionId });
7118
7138
 
7119
7139
  this.sessionNetworkStats[sessionId] = [];
7120
7140
 
@@ -7124,7 +7144,7 @@ class WebRTCClient extends Emitter {
7124
7144
  stopNetworkMonitoring(session ) {
7125
7145
  const sessionId = this.getSipSessionId(session);
7126
7146
  const exists = sessionId in this.networkMonitoringInterval;
7127
- logger$4.info('stopping network inspection', { id: sessionId, exists });
7147
+ logger$8.info('stopping network inspection', { id: sessionId, exists });
7128
7148
 
7129
7149
  if (exists) {
7130
7150
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -7134,17 +7154,17 @@ class WebRTCClient extends Emitter {
7134
7154
  }
7135
7155
 
7136
7156
  reject(session ) {
7137
- logger$4.info('sdk webrtc reject call', { id: session.id });
7157
+ logger$8.info('sdk webrtc reject call', { id: session.id });
7138
7158
 
7139
7159
  try {
7140
7160
  return session.reject ? session.reject() : session.cancel();
7141
7161
  } catch (e) {
7142
- logger$4.warn('Error when rejecting call', e.message, e.stack);
7162
+ logger$8.warn('Error when rejecting call', e.message, e.stack);
7143
7163
  }
7144
7164
  }
7145
7165
 
7146
7166
  async close() {
7147
- logger$4.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7167
+ logger$8.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
7148
7168
  this._cleanupMedia();
7149
7169
  this.connectionPromise = null;
7150
7170
 
@@ -7175,7 +7195,7 @@ class WebRTCClient extends Emitter {
7175
7195
  // eg: "INVITE not rejectable in state Completed"
7176
7196
  }
7177
7197
  this.userAgent = null;
7178
- logger$4.info('sdk webrtc client closed');
7198
+ logger$8.info('sdk webrtc client closed');
7179
7199
  }
7180
7200
 
7181
7201
  getNumber(session ) {
@@ -7188,13 +7208,13 @@ class WebRTCClient extends Emitter {
7188
7208
  }
7189
7209
 
7190
7210
  mute(session ) {
7191
- logger$4.info('sdk webrtc mute', { id: session.id });
7211
+ logger$8.info('sdk webrtc mute', { id: session.id });
7192
7212
 
7193
7213
  this._toggleAudio(session, true);
7194
7214
  }
7195
7215
 
7196
7216
  unmute(session ) {
7197
- logger$4.info('sdk webrtc unmute', { id: session.id });
7217
+ logger$8.info('sdk webrtc unmute', { id: session.id });
7198
7218
 
7199
7219
  this._toggleAudio(session, false);
7200
7220
  }
@@ -7234,13 +7254,13 @@ class WebRTCClient extends Emitter {
7234
7254
  }
7235
7255
 
7236
7256
  toggleCameraOn(session ) {
7237
- logger$4.info('sdk webrtc toggle camera on', { id: session.id });
7257
+ logger$8.info('sdk webrtc toggle camera on', { id: session.id });
7238
7258
 
7239
7259
  this._toggleVideo(session, false);
7240
7260
  }
7241
7261
 
7242
7262
  toggleCameraOff(session ) {
7243
- logger$4.info('sdk webrtc toggle camera off', { id: session.id });
7263
+ logger$8.info('sdk webrtc toggle camera off', { id: session.id });
7244
7264
 
7245
7265
  this._toggleVideo(session, true);
7246
7266
  }
@@ -7249,7 +7269,7 @@ class WebRTCClient extends Emitter {
7249
7269
  const sessionId = this.getSipSessionId(session);
7250
7270
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
7251
7271
 
7252
- logger$4.info('sdk webrtc hold', {
7272
+ logger$8.info('sdk webrtc hold', {
7253
7273
  sessionId,
7254
7274
  keys: Object.keys(this.heldSessions),
7255
7275
  pendingReinvite: !!session.pendingReinvite,
@@ -7298,7 +7318,7 @@ class WebRTCClient extends Emitter {
7298
7318
  const sessionId = this.getSipSessionId(session);
7299
7319
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7300
7320
 
7301
- logger$4.info('sdk webrtc unhold', {
7321
+ logger$8.info('sdk webrtc unhold', {
7302
7322
  sessionId,
7303
7323
  keys: Object.keys(this.heldSessions),
7304
7324
  pendingReinvite: !!session.pendingReinvite,
@@ -7446,7 +7466,7 @@ class WebRTCClient extends Emitter {
7446
7466
  if (!session.sessionDescriptionHandler) {
7447
7467
  return;
7448
7468
  }
7449
- logger$4.info('Sending DTMF', {
7469
+ logger$8.info('Sending DTMF', {
7450
7470
  id: this.getSipSessionId(session),
7451
7471
  tone,
7452
7472
  });
@@ -7462,7 +7482,7 @@ class WebRTCClient extends Emitter {
7462
7482
  transfer(session , target ) {
7463
7483
  this.hold(session);
7464
7484
 
7465
- logger$4.info('Transfering a session', {
7485
+ logger$8.info('Transfering a session', {
7466
7486
  id: this.getSipSessionId(session),
7467
7487
  target,
7468
7488
  });
@@ -7484,17 +7504,17 @@ class WebRTCClient extends Emitter {
7484
7504
  atxfer(session ) {
7485
7505
  this.hold(session);
7486
7506
 
7487
- logger$4.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7507
+ logger$8.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7488
7508
 
7489
7509
  const result = {
7490
7510
  newSession: null,
7491
7511
  init: async (target ) => {
7492
- logger$4.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7512
+ logger$8.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7493
7513
 
7494
7514
  result.newSession = await this.call(target);
7495
7515
  },
7496
7516
  complete: () => {
7497
- logger$4.info('webrtc transfer completed', {
7517
+ logger$8.info('webrtc transfer completed', {
7498
7518
  id: this.getSipSessionId(session),
7499
7519
  referId: this.getSipSessionId(result.newSession),
7500
7520
  });
@@ -7515,7 +7535,7 @@ class WebRTCClient extends Emitter {
7515
7535
  return;
7516
7536
  }
7517
7537
 
7518
- logger$4.info('send WebRTC message', { sipId: sipSession.id, contentType });
7538
+ logger$8.info('send WebRTC message', { sipId: sipSession.id, contentType });
7519
7539
 
7520
7540
  try {
7521
7541
  sipSession.message({
@@ -7557,7 +7577,7 @@ class WebRTCClient extends Emitter {
7557
7577
  }
7558
7578
 
7559
7579
  changeAudioOutputVolume(volume ) {
7560
- logger$4.info('Changing audio output volume', { volume });
7580
+ logger$8.info('Changing audio output volume', { volume });
7561
7581
 
7562
7582
  Object.values(this.audioElements).forEach(audioElement => {
7563
7583
  if (audioElement instanceof HTMLAudioElement) {
@@ -7569,7 +7589,7 @@ class WebRTCClient extends Emitter {
7569
7589
  }
7570
7590
 
7571
7591
  changeAudioOutputDevice(id ) {
7572
- logger$4.info('Changing audio output device', { id });
7592
+ logger$8.info('Changing audio output device', { id });
7573
7593
 
7574
7594
  Object.values(this.audioElements).forEach(audioElement => {
7575
7595
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7586,7 +7606,7 @@ class WebRTCClient extends Emitter {
7586
7606
 
7587
7607
  changeAudioInputDevice(id , session ) {
7588
7608
  const currentId = this.getAudioDeviceId();
7589
- logger$4.info('setting audio input device', { id, currentId, session: !!session });
7609
+ logger$8.info('setting audio input device', { id, currentId, session: !!session });
7590
7610
 
7591
7611
  if (id === currentId) {
7592
7612
  return null;
@@ -7632,7 +7652,7 @@ class WebRTCClient extends Emitter {
7632
7652
 
7633
7653
  setVideoInputDevice(id ) {
7634
7654
  const currentId = this.getVideoDeviceId();
7635
- logger$4.info('setting video input device', { id, currentId });
7655
+ logger$8.info('setting video input device', { id, currentId });
7636
7656
 
7637
7657
  if (id === currentId) {
7638
7658
  return null;
@@ -7657,7 +7677,7 @@ class WebRTCClient extends Emitter {
7657
7677
  const sessionId = this.getSipSessionId(session);
7658
7678
  const localStream = this.getLocalStream(sessionId);
7659
7679
 
7660
- logger$4.info('changing video input device', { id, sessionId });
7680
+ logger$8.info('changing video input device', { id, sessionId });
7661
7681
 
7662
7682
  // Release old video stream
7663
7683
  if (localStream) {
@@ -7725,7 +7745,7 @@ class WebRTCClient extends Emitter {
7725
7745
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7726
7746
  const desktop = newConstraints && newConstraints.desktop;
7727
7747
 
7728
- logger$4.info('Sending reinvite', {
7748
+ logger$8.info('Sending reinvite', {
7729
7749
  id: this.getSipSessionId(sipSession),
7730
7750
  newConstraints,
7731
7751
  conference,
@@ -7763,7 +7783,7 @@ class WebRTCClient extends Emitter {
7763
7783
  sipSession.incomingInviteRequest.message.body = response.message.body;
7764
7784
  }
7765
7785
 
7766
- logger$4.info('on re-INVITE accepted', {
7786
+ logger$8.info('on re-INVITE accepted', {
7767
7787
  id: this.getSipSessionId(sipSession),
7768
7788
  wasMuted,
7769
7789
  shouldDoScreenSharing,
@@ -7781,7 +7801,7 @@ class WebRTCClient extends Emitter {
7781
7801
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7782
7802
  }
7783
7803
 
7784
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7804
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7785
7805
  },
7786
7806
  },
7787
7807
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7938,7 +7958,7 @@ class WebRTCClient extends Emitter {
7938
7958
  }
7939
7959
 
7940
7960
  startHeartbeat() {
7941
- logger$4.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7961
+ logger$8.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7942
7962
  if (!this.userAgent) {
7943
7963
  this.heartbeat.stop();
7944
7964
  return;
@@ -7951,7 +7971,7 @@ class WebRTCClient extends Emitter {
7951
7971
  }
7952
7972
 
7953
7973
  stopHeartbeat() {
7954
- logger$4.info('sdk webrtc stop heartbeat');
7974
+ logger$8.info('sdk webrtc stop heartbeat');
7955
7975
  this.heartbeat.stop();
7956
7976
  }
7957
7977
 
@@ -7972,7 +7992,7 @@ class WebRTCClient extends Emitter {
7972
7992
  }
7973
7993
 
7974
7994
  attemptReconnection() {
7975
- logger$4.info('attempt reconnection', { userAgent: !!this.userAgent });
7995
+ logger$8.info('attempt reconnection', { userAgent: !!this.userAgent });
7976
7996
  if (!this.userAgent) {
7977
7997
  return;
7978
7998
  }
@@ -7997,7 +8017,7 @@ class WebRTCClient extends Emitter {
7997
8017
  return;
7998
8018
  }
7999
8019
 
8000
- logger$4.info('setting local media stream', {
8020
+ logger$8.info('setting local media stream', {
8001
8021
  sipSessionId,
8002
8022
  tracks: newStream ? newStream.getTracks() : null,
8003
8023
  });
@@ -8014,7 +8034,7 @@ class WebRTCClient extends Emitter {
8014
8034
 
8015
8035
  const oldStream = this.getLocalStream(sipSessionId);
8016
8036
 
8017
- logger$4.info('updating local stream', {
8037
+ logger$8.info('updating local stream', {
8018
8038
  sipSessionId,
8019
8039
  oldStream: !!oldStream,
8020
8040
  tracks: newStream.getTracks(),
@@ -8034,7 +8054,7 @@ class WebRTCClient extends Emitter {
8034
8054
  const remoteStream = this.getRemoteStream(sessionId);
8035
8055
  const pc = this.getPeerConnection(sessionId);
8036
8056
 
8037
- logger$4.info('Updating remote stream', {
8057
+ logger$8.info('Updating remote stream', {
8038
8058
  sessionId,
8039
8059
  tracks: remoteStream ? remoteStream.getTracks() : null,
8040
8060
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -8059,14 +8079,16 @@ class WebRTCClient extends Emitter {
8059
8079
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
8060
8080
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
8061
8081
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
8082
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
8062
8083
 
8063
- logger$4.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8084
+ logger$8.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
8064
8085
 
8065
8086
  return {
8066
8087
  constraints: {
8067
8088
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
8068
8089
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
8069
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
8090
+ video: screenSharing ? (isDesktop
8091
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
8070
8092
  : this._getVideoConstraints(enableVideo),
8071
8093
  screen: screenSharing,
8072
8094
  desktop: isDesktop,
@@ -8109,7 +8131,7 @@ class WebRTCClient extends Emitter {
8109
8131
  }
8110
8132
 
8111
8133
  _onTransportError() {
8112
- logger$4.error('on transport error');
8134
+ logger$8.error('on transport error');
8113
8135
  this.eventEmitter.emit(TRANSPORT_ERROR);
8114
8136
  this.attemptReconnection();
8115
8137
  }
@@ -8118,7 +8140,7 @@ class WebRTCClient extends Emitter {
8118
8140
  const body = message && typeof message === 'object' ? message.data : message;
8119
8141
  if (body && body.indexOf('200 OK') !== -1) {
8120
8142
  if (this.hasHeartbeat()) {
8121
- logger$4.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8143
+ logger$8.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
8122
8144
 
8123
8145
  this.heartbeat.onHeartbeat();
8124
8146
  if (this.heartbeatCb) {
@@ -8129,7 +8151,7 @@ class WebRTCClient extends Emitter {
8129
8151
  }
8130
8152
 
8131
8153
  async _onHeartbeatTimeout() {
8132
- logger$4.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8154
+ logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8133
8155
 
8134
8156
  if (this.heartbeatTimeoutCb) {
8135
8157
  this.heartbeatTimeoutCb();
@@ -8141,7 +8163,7 @@ class WebRTCClient extends Emitter {
8141
8163
  try {
8142
8164
  await this.userAgent.transport.disconnect();
8143
8165
  } catch (e) {
8144
- logger$4.error('Transport disconnection after heartbeat timeout, error', e);
8166
+ logger$8.error('Transport disconnection after heartbeat timeout, error', e);
8145
8167
  }
8146
8168
  }
8147
8169
 
@@ -8174,31 +8196,31 @@ class WebRTCClient extends Emitter {
8174
8196
  }
8175
8197
 
8176
8198
  _connectIfNeeded() {
8177
- logger$4.info('connect if needed, checking', { connected: this.isConnected() });
8199
+ logger$8.info('connect if needed, checking', { connected: this.isConnected() });
8178
8200
  if (!this.userAgent) {
8179
- logger$4.info('need to recreate User Agent');
8201
+ logger$8.info('need to recreate User Agent');
8180
8202
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
8181
8203
  }
8182
8204
 
8183
8205
  if (this.isConnected()) {
8184
- logger$4.info('webrtc sdk, already connected');
8206
+ logger$8.info('webrtc sdk, already connected');
8185
8207
  return Promise.resolve();
8186
8208
  }
8187
8209
 
8188
8210
  if (this.isConnecting()) {
8189
- logger$4.info('webrtc sdk, already connecting...');
8211
+ logger$8.info('webrtc sdk, already connecting...');
8190
8212
 
8191
8213
  this.connectionPromise = this.userAgent.transport.connectPromise;
8192
8214
  return this.connectionPromise;
8193
8215
  }
8194
8216
 
8195
8217
  if (this.connectionPromise) {
8196
- logger$4.info('webrtc sdk, connection promise connecting...');
8218
+ logger$8.info('webrtc sdk, connection promise connecting...');
8197
8219
  // $FlowFixMe
8198
8220
  return this.connectionPromise;
8199
8221
  }
8200
8222
 
8201
- logger$4.info('WebRTC UA needs to connect');
8223
+ logger$8.info('WebRTC UA needs to connect');
8202
8224
 
8203
8225
  // Force UA to reconnect
8204
8226
  if (this.userAgent && this.userAgent.state !== userAgentState.UserAgentState.Stopped) {
@@ -8323,7 +8345,7 @@ class WebRTCClient extends Emitter {
8323
8345
 
8324
8346
  sdh.peerConnectionDelegate = {
8325
8347
  onicecandidateerror: (error ) => {
8326
- logger$4.error('on icecandidate error', {
8348
+ logger$8.error('on icecandidate error', {
8327
8349
  address: error.address,
8328
8350
  port: error.port,
8329
8351
  errorCode: error.errorCode,
@@ -8352,7 +8374,7 @@ class WebRTCClient extends Emitter {
8352
8374
  updatedNumber = session.assertedIdentity.uri.normal.user;
8353
8375
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8354
8376
  }
8355
- logger$4.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8377
+ logger$8.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8356
8378
 
8357
8379
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8358
8380
 
@@ -8368,12 +8390,12 @@ class WebRTCClient extends Emitter {
8368
8390
 
8369
8391
  this._setupMedias(session);
8370
8392
 
8371
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8393
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8372
8394
  };
8373
8395
  }
8374
8396
 
8375
8397
  _onAccepted(session , sessionDialog , withEvent = true) {
8376
- logger$4.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8398
+ logger$8.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8377
8399
 
8378
8400
  this.storeSipSession(session);
8379
8401
 
@@ -8385,14 +8407,14 @@ class WebRTCClient extends Emitter {
8385
8407
  const onTrack = (event ) => {
8386
8408
  const isAudioOnly = this._isAudioOnly(session);
8387
8409
  const { kind, label, readyState, id, muted } = event.track;
8388
- logger$4.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8410
+ logger$8.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8389
8411
 
8390
8412
  // Stop video track in audio only mode
8391
8413
  if (isAudioOnly && kind === 'video') {
8392
8414
  event.track.stop();
8393
8415
  }
8394
8416
 
8395
- this.eventEmitter.emit(ON_TRACK, session, event);
8417
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
8396
8418
  };
8397
8419
 
8398
8420
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8401,12 +8423,14 @@ class WebRTCClient extends Emitter {
8401
8423
 
8402
8424
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8403
8425
 
8404
- pc.oniceconnectionstatechange = () => {
8405
- logger$4.info('on ice connection state changed', { state: pc.iceConnectionState });
8406
- if (pc.iceConnectionState === 'disconnected') {
8407
- this.eventEmitter.emit(ON_DISCONNECTED);
8408
- }
8409
- };
8426
+ if (pc) {
8427
+ pc.oniceconnectionstatechange = () => {
8428
+ logger$8.info('on ice connection state changed', { state: pc.iceConnectionState });
8429
+ if (pc.iceConnectionState === 'disconnected') {
8430
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8431
+ }
8432
+ };
8433
+ }
8410
8434
 
8411
8435
  if (withEvent) {
8412
8436
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8575,10 +8599,10 @@ class WebRTCClient extends Emitter {
8575
8599
 
8576
8600
  _stopSendingStats(session ) {
8577
8601
  const sessionId = this.getSipSessionId(session);
8578
- logger$4.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8602
+ logger$8.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8579
8603
 
8580
8604
  if (sessionId in this.statsIntervals) {
8581
- logger$4.trace('Stop sending stats for call', { sessionId });
8605
+ logger$8.trace('Stop sending stats for call', { sessionId });
8582
8606
  this.statsIntervals[sessionId]();
8583
8607
  delete this.statsIntervals[sessionId];
8584
8608
  }
@@ -8594,7 +8618,7 @@ class WebRTCClient extends Emitter {
8594
8618
  try {
8595
8619
  await this.userAgent.transport.disconnect();
8596
8620
  } catch (e) {
8597
- logger$4.error('WebRTC transport disconnect, error', e);
8621
+ logger$8.error('WebRTC transport disconnect, error', e);
8598
8622
  }
8599
8623
  }
8600
8624
  }
@@ -8616,13 +8640,17 @@ class WebRTCClient extends Emitter {
8616
8640
  const nbStats = this.sessionNetworkStats[sessionId].length;
8617
8641
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8618
8642
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8643
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8619
8644
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8620
8645
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8646
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8621
8647
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8622
8648
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8623
8649
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8624
- let audioBytesSent = 0;
8625
- let audioBytesReceived = 0;
8650
+ let audioBytesSent = 0; // content + header
8651
+ let audioBytesReceived = 0; // content + header
8652
+ let audioContentSent = 0; // useful to detect blank call
8653
+ let audioContentReceived = 0;
8626
8654
  let videoBytesSent = 0;
8627
8655
  let videoBytesReceived = 0;
8628
8656
  let transportSent = 0;
@@ -8632,6 +8660,7 @@ class WebRTCClient extends Emitter {
8632
8660
  stats.forEach(report => {
8633
8661
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8634
8662
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8663
+ audioContentSent += Number(report.bytesSent);
8635
8664
  }
8636
8665
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8637
8666
  audioBytesSent += Number(report.bytesSent);
@@ -8643,6 +8672,7 @@ class WebRTCClient extends Emitter {
8643
8672
  packetsLost += Number(report.packetsLost);
8644
8673
  networkStats.packetsReceived = Number(report.packetsReceived);
8645
8674
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8675
+ audioContentReceived += Number(report.bytesReceived);
8646
8676
  }
8647
8677
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8648
8678
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8671,10 +8701,17 @@ class WebRTCClient extends Emitter {
8671
8701
  });
8672
8702
 
8673
8703
  networkStats.packetsLost = packetsLost;
8704
+
8674
8705
  networkStats.totalAudioBytesSent = audioBytesSent;
8675
8706
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8676
8707
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8677
8708
  networkStats.audioBytesReceived = audioBytesReceived;
8709
+
8710
+ networkStats.totalAudioContentSent = audioContentSent;
8711
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8712
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8713
+ networkStats.audioContentReceived = audioContentReceived;
8714
+
8678
8715
  networkStats.totalVideoBytesSent = videoBytesSent;
8679
8716
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8680
8717
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8688,7 +8725,7 @@ class WebRTCClient extends Emitter {
8688
8725
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8689
8726
  + networkStats.transportSent;
8690
8727
 
8691
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8728
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8692
8729
  this.sessionNetworkStats[sessionId].push(networkStats);
8693
8730
  }
8694
8731
 
@@ -8713,11 +8750,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8713
8750
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8714
8751
  const ON_CALL_CANCELED = 'onCallCanceled';
8715
8752
  const ON_CALL_FAILED = 'onCallFailed';
8753
+ const ON_CALL_REJECTED = 'onCallRejected';
8716
8754
  const ON_CALL_ENDED = 'onCallEnded';
8717
8755
  const ON_CALL_ENDING = 'onCallEnding';
8718
8756
  const ON_MESSAGE = 'onMessage';
8719
- const ON_REINVITE$1 = 'reinvite';
8720
- const ON_TRACK$1 = 'onTrack';
8757
+ const ON_REINVITE = 'reinvite';
8758
+ const ON_TRACK = 'onTrack';
8721
8759
  const ON_AUDIO_STREAM = 'onAudioStream';
8722
8760
  const ON_VIDEO_STREAM = 'onVideoStream';
8723
8761
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8732,15 +8770,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8732
8770
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8733
8771
  const ON_CALL_ERROR = 'onCallError';
8734
8772
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8735
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
8773
+ const ON_NETWORK_STATS = 'onNetworkStats';
8736
8774
  const ON_CHAT = 'phone/ON_CHAT';
8737
8775
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8738
- const ON_DISCONNECTED$1 = 'onDisconnected';
8776
+ const ON_DISCONNECTED = 'onDisconnected';
8739
8777
 
8740
8778
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8741
8779
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8742
8780
 
8743
- const events$1 = [
8781
+ const events = [
8744
8782
  ON_USER_AGENT,
8745
8783
  ON_REGISTERED,
8746
8784
  ON_UNREGISTERED,
@@ -8757,9 +8795,10 @@ const events$1 = [
8757
8795
  ON_CAMERA_DISABLED,
8758
8796
  ON_CALL_FAILED,
8759
8797
  ON_CALL_ENDED,
8798
+ ON_CALL_REJECTED,
8760
8799
  ON_MESSAGE,
8761
- ON_REINVITE$1,
8762
- ON_TRACK$1,
8800
+ ON_REINVITE,
8801
+ ON_TRACK,
8763
8802
  ON_AUDIO_STREAM,
8764
8803
  ON_VIDEO_STREAM,
8765
8804
  ON_REMOVE_STREAM,
@@ -8774,11 +8813,11 @@ const events$1 = [
8774
8813
  ON_CALL_ERROR,
8775
8814
  ON_CHAT,
8776
8815
  ON_SIGNAL,
8777
- ON_NETWORK_STATS$1,
8778
- ON_DISCONNECTED$1,
8816
+ ON_NETWORK_STATS,
8817
+ ON_DISCONNECTED,
8779
8818
  ];
8780
8819
 
8781
- const logger$5 = IssueReporter$1.loggerFor('webrtc-phone');
8820
+ const logger$7 = IssueReporter$1.loggerFor('webrtc-phone');
8782
8821
 
8783
8822
  class WebRTCPhone extends Emitter {
8784
8823
 
@@ -8851,7 +8890,7 @@ class WebRTCPhone extends Emitter {
8851
8890
  }).catch(error => {
8852
8891
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8853
8892
  console.error('register error', error, error.message, error.stack);
8854
- logger$5.error('WebRTC register error', { message: error.message, stack: error.stack });
8893
+ logger$7.error('WebRTC register error', { message: error.message, stack: error.stack });
8855
8894
  });
8856
8895
  }
8857
8896
 
@@ -8866,7 +8905,7 @@ class WebRTCPhone extends Emitter {
8866
8905
  if (!this.client) {
8867
8906
  return;
8868
8907
  }
8869
- logger$5.info('WebRTC phone stop');
8908
+ logger$7.info('WebRTC phone stop');
8870
8909
  this.client.stop();
8871
8910
  }
8872
8911
 
@@ -8881,11 +8920,12 @@ class WebRTCPhone extends Emitter {
8881
8920
  async sendReinvite(callSession , constraints = null, conference = false,
8882
8921
  audioOnly = false, iceRestart = false) {
8883
8922
  const sipSession = this.findSipSession(callSession);
8884
- logger$5.info('WebRTC phone - send reinvite', {
8923
+ logger$7.info('WebRTC phone - send reinvite', {
8885
8924
  sessionId: sipSession ? sipSession.id : null,
8886
8925
  constraints,
8887
8926
  audioOnly,
8888
8927
  conference,
8928
+ iceRestart,
8889
8929
  });
8890
8930
 
8891
8931
  if (!sipSession) {
@@ -8918,7 +8958,7 @@ class WebRTCPhone extends Emitter {
8918
8958
  }
8919
8959
 
8920
8960
  startHeartbeat() {
8921
- logger$5.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8961
+ logger$7.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8922
8962
  if (!this.client || this.client.hasHeartbeat()) {
8923
8963
  return;
8924
8964
  }
@@ -8927,7 +8967,7 @@ class WebRTCPhone extends Emitter {
8927
8967
  }
8928
8968
 
8929
8969
  stopHeartbeat() {
8930
- logger$5.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8970
+ logger$7.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8931
8971
  if (!this.client) {
8932
8972
  return;
8933
8973
  }
@@ -8944,7 +8984,7 @@ class WebRTCPhone extends Emitter {
8944
8984
  }
8945
8985
 
8946
8986
  reconnect() {
8947
- logger$5.info('WebRTC phone - reconnect', { client: !!this.client });
8987
+ logger$7.info('WebRTC phone - reconnect', { client: !!this.client });
8948
8988
  if (!this.client) {
8949
8989
  return;
8950
8990
  }
@@ -8985,7 +9025,7 @@ class WebRTCPhone extends Emitter {
8985
9025
  return false;
8986
9026
  }
8987
9027
 
8988
- logger$5.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
9028
+ logger$7.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8989
9029
 
8990
9030
  this.client.downgradeToAudio(sipSession);
8991
9031
 
@@ -9008,7 +9048,7 @@ class WebRTCPhone extends Emitter {
9008
9048
  return Promise.resolve(false);
9009
9049
  }
9010
9050
 
9011
- logger$5.info('Upgrade to video', {
9051
+ logger$7.info('Upgrade to video', {
9012
9052
  id: callSession ? callSession.getId() : null,
9013
9053
  constraints,
9014
9054
  isConference,
@@ -9048,7 +9088,7 @@ class WebRTCPhone extends Emitter {
9048
9088
 
9049
9089
  _sendReinviteMessage(callSession , isUpgrade ) {
9050
9090
  const sipSession = this.findSipSession(callSession);
9051
- logger$5.info('Sending reinvite message', {
9091
+ logger$7.info('Sending reinvite message', {
9052
9092
  id: callSession ? callSession.getId() : null,
9053
9093
  isUpgrade,
9054
9094
  });
@@ -9074,7 +9114,7 @@ class WebRTCPhone extends Emitter {
9074
9114
  // Monkey patch to know when canceled with the CANCEL message
9075
9115
  const onCancel = sipSession._onCancel.bind(sipSession);
9076
9116
  sipSession._onCancel = (message ) => {
9077
- logger$5.trace('on sip session canceled', { callId: message.callId });
9117
+ logger$7.trace('on sip session canceled', { callId: message.callId });
9078
9118
 
9079
9119
  onCancel(message);
9080
9120
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -9102,16 +9142,17 @@ class WebRTCPhone extends Emitter {
9102
9142
  this.audioOutputVolume,
9103
9143
  );
9104
9144
  case sessionState.SessionState.Terminating:
9105
- logger$5.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9145
+ logger$7.info('WebRTC phone - call terminating', { sipId: sipSession.id });
9106
9146
 
9107
9147
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
9108
9148
 
9109
9149
  break;
9110
9150
  case sessionState.SessionState.Terminated: {
9111
- logger$5.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9151
+ logger$7.info('WebRTC phone - call terminated', { sipId: sipSession.id });
9112
9152
 
9113
9153
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
9114
9154
  const callSession = this._createCallSession(sipSession);
9155
+ callSession.endTime = new Date();
9115
9156
  const wasCurrentSession = this._onCallTerminated(sipSession);
9116
9157
 
9117
9158
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -9130,7 +9171,7 @@ class WebRTCPhone extends Emitter {
9130
9171
  const [stream] = event.streams;
9131
9172
  const kind = event && event.track && event.track.kind;
9132
9173
 
9133
- logger$5.info('on track stream called on the peer connection', {
9174
+ logger$7.info('on track stream called on the peer connection', {
9134
9175
  callId: this.getSipSessionId(sipSession),
9135
9176
  streamId: stream ? stream.id : null,
9136
9177
  tracks: stream ? stream.getTracks() : null,
@@ -9150,7 +9191,7 @@ class WebRTCPhone extends Emitter {
9150
9191
  };
9151
9192
 
9152
9193
  peerConnection.onremovestream = event => {
9153
- logger$5.info('on remove stream called on the peer connection', {
9194
+ logger$7.info('on remove stream called on the peer connection', {
9154
9195
  id: event.stream.id,
9155
9196
  tracks: event.stream.getTracks(),
9156
9197
  });
@@ -9160,7 +9201,7 @@ class WebRTCPhone extends Emitter {
9160
9201
  }
9161
9202
 
9162
9203
  async startScreenSharing(constraints , callSession ) {
9163
- logger$5.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9204
+ logger$7.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
9164
9205
 
9165
9206
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
9166
9207
  if (!screenShareStream) {
@@ -9200,7 +9241,7 @@ class WebRTCPhone extends Emitter {
9200
9241
  return;
9201
9242
  }
9202
9243
 
9203
- logger$5.info('WebRTC phone - stop screen sharing', {
9244
+ logger$7.info('WebRTC phone - stop screen sharing', {
9204
9245
  restoreLocalStream,
9205
9246
  });
9206
9247
 
@@ -9256,7 +9297,7 @@ class WebRTCPhone extends Emitter {
9256
9297
  const pc = this.client.getPeerConnection(sipSessionId);
9257
9298
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
9258
9299
 
9259
- logger$5.info('WebRTC phone - on screensharing', {
9300
+ logger$7.info('WebRTC phone - on screensharing', {
9260
9301
  hadVideo,
9261
9302
  id: this.getSipSessionId(sipSession),
9262
9303
  screenTrack,
@@ -9264,7 +9305,7 @@ class WebRTCPhone extends Emitter {
9264
9305
 
9265
9306
  if (screenTrack) {
9266
9307
  screenTrack.onended = () => {
9267
- logger$5.info('WebRTC phone - on screenshare ended', {
9308
+ logger$7.info('WebRTC phone - on screenshare ended', {
9268
9309
  hadVideo,
9269
9310
  id: this.getSipSessionId(sipSession),
9270
9311
  screenTrack,
@@ -9295,7 +9336,7 @@ class WebRTCPhone extends Emitter {
9295
9336
  }
9296
9337
 
9297
9338
  _onCallAccepted(sipSession , cameraEnabled ) {
9298
- logger$5.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9339
+ logger$7.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9299
9340
 
9300
9341
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9301
9342
  this.currentSipSession = sipSession;
@@ -9313,7 +9354,7 @@ class WebRTCPhone extends Emitter {
9313
9354
  }
9314
9355
 
9315
9356
  changeAudioDevice(id ) {
9316
- logger$5.info('WebRTC phone - change audio device', { deviceId: id });
9357
+ logger$7.info('WebRTC phone - change audio device', { deviceId: id });
9317
9358
  this.audioOutputDeviceId = id;
9318
9359
  this.client.changeAudioOutputDevice(id);
9319
9360
  }
@@ -9323,14 +9364,14 @@ class WebRTCPhone extends Emitter {
9323
9364
  }
9324
9365
 
9325
9366
  changeRingDevice(id ) {
9326
- logger$5.info('WebRTC phone - changing ring device', { id });
9367
+ logger$7.info('WebRTC phone - changing ring device', { id });
9327
9368
 
9328
9369
  this.audioRingDeviceId = id;
9329
9370
  }
9330
9371
 
9331
9372
  // volume is a value between 0 and 1
9332
9373
  changeAudioVolume(volume ) {
9333
- logger$5.info('WebRTC phone - changing audio volume', { volume });
9374
+ logger$7.info('WebRTC phone - changing audio volume', { volume });
9334
9375
 
9335
9376
  this.audioOutputVolume = volume;
9336
9377
  this.client.changeAudioOutputVolume(volume);
@@ -9338,32 +9379,33 @@ class WebRTCPhone extends Emitter {
9338
9379
 
9339
9380
  // volume is a value between 0 and 1
9340
9381
  changeRingVolume(volume ) {
9341
- logger$5.info('WebRTC phone - changing ring volume', { volume });
9382
+ logger$7.info('WebRTC phone - changing ring volume', { volume });
9342
9383
 
9343
9384
  this.audioRingVolume = volume;
9344
9385
  }
9345
9386
 
9346
9387
  changeAudioInputDevice(id ) {
9347
- logger$5.info('WebRTC phone - changeAudio input device', { deviceId: id });
9388
+ logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9348
9389
 
9349
9390
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9350
9391
  }
9351
9392
 
9352
9393
  changeVideoInputDevice(id ) {
9353
- logger$5.info('WebRTC phone - change video input device', { deviceId: id });
9394
+ logger$7.info('WebRTC phone - change video input device', { deviceId: id });
9354
9395
 
9355
9396
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9356
9397
  }
9357
9398
 
9358
9399
  changeSessionVideoInputDevice(id ) {
9359
- logger$5.info('WebRTC phone - change session video input device', { deviceId: id });
9400
+ logger$7.info('WebRTC phone - change session video input device', { deviceId: id });
9360
9401
 
9361
9402
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9362
9403
  }
9363
9404
 
9364
9405
  _onCallTerminated(sipSession ) {
9365
- logger$5.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9406
+ logger$7.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9366
9407
 
9408
+ const sipSessionId = this.getSipSessionId(sipSession);
9367
9409
  const callSession = this._createCallSession(sipSession);
9368
9410
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9369
9411
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9381,7 +9423,6 @@ class WebRTCPhone extends Emitter {
9381
9423
  }, 5);
9382
9424
  }
9383
9425
 
9384
- const sipSessionId = this.getSipSessionId(sipSession);
9385
9426
  if (sipSessionId) {
9386
9427
  this.removeIncomingSessions(sipSessionId);
9387
9428
  }
@@ -9396,7 +9437,7 @@ class WebRTCPhone extends Emitter {
9396
9437
  const hasIncomingCallSession = this.hasIncomingCallSession();
9397
9438
 
9398
9439
  // Re-trigger incoming call event for remaining incoming calls
9399
- logger$5.info('WebRTC phone - check to re-trigger incoming call', {
9440
+ logger$7.info('WebRTC phone - check to re-trigger incoming call', {
9400
9441
  sipId: sipSession.id,
9401
9442
  shouldRetrigger,
9402
9443
  hasIncomingCallSession,
@@ -9487,37 +9528,37 @@ class WebRTCPhone extends Emitter {
9487
9528
 
9488
9529
  // Deprecated
9489
9530
  getLocalStreamForCall(callSession ) {
9490
- logger$5.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9531
+ logger$7.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9491
9532
 
9492
9533
  return this.getLocalStream(callSession);
9493
9534
  }
9494
9535
 
9495
9536
  // Deprecated
9496
9537
  getRemoteStreamForCall(callSession ) {
9497
- logger$5.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9538
+ logger$7.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9498
9539
 
9499
9540
  return this.getRemoteVideoStream(callSession);
9500
9541
  }
9501
9542
 
9502
9543
  getRemoteStreamsForCall(callSession ) {
9503
- logger$5.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9544
+ logger$7.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9504
9545
 
9505
9546
  return this.getRemoteStream(callSession);
9506
9547
  }
9507
9548
 
9508
9549
  accept(callSession , cameraEnabled ) {
9509
- logger$5.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9550
+ logger$7.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9510
9551
  if (this.currentSipSession) {
9511
9552
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9512
9553
  }
9513
9554
 
9514
9555
  if (!callSession) {
9515
- logger$5.warn('no CallSession to accept.');
9556
+ logger$7.warn('no CallSession to accept.');
9516
9557
  return Promise.resolve(null);
9517
9558
  }
9518
9559
 
9519
9560
  if (callSession.getId() in this.acceptedSessions) {
9520
- logger$5.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9561
+ logger$7.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9521
9562
  return Promise.resolve(callSession.sipCallId);
9522
9563
  }
9523
9564
 
@@ -9529,24 +9570,24 @@ class WebRTCPhone extends Emitter {
9529
9570
  const sipSession = this.client.getSipSession(callSession.getId());
9530
9571
  if (sipSession) {
9531
9572
  if (sipSession.state === sessionState.SessionState.Terminated || sipSession.state === sessionState.SessionState.Terminating) {
9532
- logger$5.warn('Trying to answer a terminated sipSession.');
9573
+ logger$7.warn('Trying to answer a terminated sipSession.');
9533
9574
 
9534
9575
  return Promise.resolve(null);
9535
9576
  }
9536
9577
 
9537
- logger$5.info('accept call, session found', { sipId: sipSession.id });
9578
+ logger$7.info('accept call, session found', { sipId: sipSession.id });
9538
9579
 
9539
9580
  // $FlowFixMe
9540
9581
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9541
9582
  return callSession.sipCallId;
9542
9583
  }).catch(e => {
9543
- logger$5.error(e);
9584
+ logger$7.error(e);
9544
9585
  this.endCurrentCall(callSession);
9545
9586
  throw e;
9546
9587
  });
9547
9588
  }
9548
9589
 
9549
- logger$5.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9590
+ logger$7.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9550
9591
 
9551
9592
  return Promise.resolve(null);
9552
9593
  }
@@ -9556,7 +9597,7 @@ class WebRTCPhone extends Emitter {
9556
9597
  }
9557
9598
 
9558
9599
  async reject(callSession ) {
9559
- logger$5.info('reject WebRTC called', { id: callSession.getId() });
9600
+ logger$7.info('reject WebRTC called', { id: callSession.getId() });
9560
9601
 
9561
9602
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9562
9603
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9568,14 +9609,14 @@ class WebRTCPhone extends Emitter {
9568
9609
 
9569
9610
  const sipSession = this.findSipSession(callSession);
9570
9611
  if (sipSession) {
9571
- logger$5.info('WebRTC rejecting', { sipId: sipSession.id });
9612
+ logger$7.info('WebRTC rejecting', { sipId: sipSession.id });
9572
9613
 
9573
9614
  this.client.hangup(sipSession);
9574
9615
  }
9575
9616
  }
9576
9617
 
9577
9618
  async ignore(callSession ) {
9578
- logger$5.info('WebRTC ignore', { id: callSession.getId() });
9619
+ logger$7.info('WebRTC ignore', { id: callSession.getId() });
9579
9620
 
9580
9621
  // kill the ring
9581
9622
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9587,14 +9628,14 @@ class WebRTCPhone extends Emitter {
9587
9628
  const sipSession = this.findSipSession(callSession);
9588
9629
 
9589
9630
  if (sipSession) {
9590
- logger$5.info('WebRTC atxfer', { sipId: sipSession.id });
9631
+ logger$7.info('WebRTC atxfer', { sipId: sipSession.id });
9591
9632
 
9592
9633
  return this.client.atxfer(sipSession);
9593
9634
  }
9594
9635
  }
9595
9636
 
9596
9637
  hold(callSession , withEvent = true, isConference = false) {
9597
- logger$5.info('WebRTC hold', { id: callSession.getId() });
9638
+ logger$7.info('WebRTC hold', { id: callSession.getId() });
9598
9639
 
9599
9640
  const sipSession = this.findSipSession(callSession);
9600
9641
 
@@ -9609,18 +9650,18 @@ class WebRTCPhone extends Emitter {
9609
9650
  }
9610
9651
 
9611
9652
  resume(callSession , isConference = false, withEvent = true) {
9612
- logger$5.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9653
+ logger$7.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9613
9654
 
9614
9655
  const sipSession = this.findSipSession(callSession);
9615
9656
  if (!sipSession) {
9616
9657
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9617
9658
  }
9618
9659
 
9619
- logger$5.info('WebRTC resuming', { sipId: sipSession.id });
9660
+ logger$7.info('WebRTC resuming', { sipId: sipSession.id });
9620
9661
 
9621
9662
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9622
9663
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9623
- logger$5.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9664
+ logger$7.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9624
9665
  this.holdSipSession(this.currentSipSession, callSession);
9625
9666
  }
9626
9667
 
@@ -9645,7 +9686,7 @@ class WebRTCPhone extends Emitter {
9645
9686
  const sessionId = this.getSipSessionId(sipSession);
9646
9687
  const hasVideo = this.client.hasLocalVideo(sessionId);
9647
9688
 
9648
- logger$5.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9689
+ logger$7.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9649
9690
 
9650
9691
  // Stop screenshre if needed
9651
9692
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9676,7 +9717,7 @@ class WebRTCPhone extends Emitter {
9676
9717
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9677
9718
  }
9678
9719
  const sessionId = this.getSipSessionId(sipSession);
9679
- logger$5.info('WebRTC unhold sip session', { sessionId, isConference });
9720
+ logger$7.info('WebRTC unhold sip session', { sessionId, isConference });
9680
9721
 
9681
9722
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9682
9723
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9720,14 +9761,14 @@ class WebRTCPhone extends Emitter {
9720
9761
  }
9721
9762
 
9722
9763
  mute(callSession , withEvent = true) {
9723
- logger$5.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9764
+ logger$7.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9724
9765
 
9725
9766
  const sipSession = this.findSipSession(callSession);
9726
9767
  if (!sipSession) {
9727
9768
  return;
9728
9769
  }
9729
9770
 
9730
- logger$5.info('WebRTC muting', { sipId: sipSession.id });
9771
+ logger$7.info('WebRTC muting', { sipId: sipSession.id });
9731
9772
  this.client.mute(sipSession);
9732
9773
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9733
9774
 
@@ -9741,14 +9782,14 @@ class WebRTCPhone extends Emitter {
9741
9782
  }
9742
9783
 
9743
9784
  unmute(callSession , withEvent = true) {
9744
- logger$5.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9785
+ logger$7.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9745
9786
 
9746
9787
  const sipSession = this.findSipSession(callSession);
9747
9788
  if (!sipSession) {
9748
9789
  return;
9749
9790
  }
9750
9791
 
9751
- logger$5.info('WebRTC unmuting', { sipId: sipSession.id });
9792
+ logger$7.info('WebRTC unmuting', { sipId: sipSession.id });
9752
9793
  this.client.unmute(sipSession);
9753
9794
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9754
9795
 
@@ -9775,7 +9816,7 @@ class WebRTCPhone extends Emitter {
9775
9816
  if (!sipSession) {
9776
9817
  return;
9777
9818
  }
9778
- logger$5.info('WebRTC turn camera on', { sipId: sipSession.id });
9819
+ logger$7.info('WebRTC turn camera on', { sipId: sipSession.id });
9779
9820
 
9780
9821
  this.client.toggleCameraOn(sipSession);
9781
9822
 
@@ -9787,7 +9828,7 @@ class WebRTCPhone extends Emitter {
9787
9828
  if (!sipSession) {
9788
9829
  return;
9789
9830
  }
9790
- logger$5.info('WebRTC turn camera off', { sipId: sipSession.id });
9831
+ logger$7.info('WebRTC turn camera off', { sipId: sipSession.id });
9791
9832
 
9792
9833
  this.client.toggleCameraOff(sipSession);
9793
9834
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9799,7 +9840,7 @@ class WebRTCPhone extends Emitter {
9799
9840
  return;
9800
9841
  }
9801
9842
 
9802
- logger$5.info('WebRTC send key', { sipId: sipSession.id, tone });
9843
+ logger$7.info('WebRTC send key', { sipId: sipSession.id, tone });
9803
9844
  this.client.sendDTMF(sipSession, tone);
9804
9845
  }
9805
9846
 
@@ -9807,7 +9848,7 @@ class WebRTCPhone extends Emitter {
9807
9848
  // @TODO: line is not used here
9808
9849
  async makeCall(number , line , cameraEnabled ,
9809
9850
  audioOnly = false, conference = false) {
9810
- logger$5.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9851
+ logger$7.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
9811
9852
  if (!number) {
9812
9853
  return Promise.resolve(null);
9813
9854
  }
@@ -9817,7 +9858,7 @@ class WebRTCPhone extends Emitter {
9817
9858
  }
9818
9859
  if (this.currentSipSession) {
9819
9860
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9820
- logger$5.warn('Unable to hold current session when making another call', e);
9861
+ logger$7.warn('Unable to hold current session when making another call', e);
9821
9862
  });
9822
9863
  }
9823
9864
 
@@ -9827,10 +9868,11 @@ class WebRTCPhone extends Emitter {
9827
9868
  this._bindEvents(sipSession);
9828
9869
  } catch (error) {
9829
9870
  console.warn(error);
9830
- logger$5.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9871
+ logger$7.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9831
9872
  return Promise.resolve(null);
9832
9873
  }
9833
9874
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9875
+ callSession.creationTime = new Date();
9834
9876
 
9835
9877
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9836
9878
 
@@ -9855,7 +9897,7 @@ class WebRTCPhone extends Emitter {
9855
9897
  return;
9856
9898
  }
9857
9899
 
9858
- logger$5.info('WebRTC transfer', { sipId: sipSession.id, target });
9900
+ logger$7.info('WebRTC transfer', { sipId: sipSession.id, target });
9859
9901
 
9860
9902
  this.client.transfer(sipSession, target);
9861
9903
  }
@@ -9864,7 +9906,7 @@ class WebRTCPhone extends Emitter {
9864
9906
  const sipSession = this.client.getSipSession(source.sipCallId);
9865
9907
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9866
9908
 
9867
- logger$5.info('WebRTC indirect transfer', {
9909
+ logger$7.info('WebRTC indirect transfer', {
9868
9910
  sipId: sipSession ? sipSession.id : null,
9869
9911
  target: sipSessionTarget ? sipSessionTarget.id : null,
9870
9912
  });
@@ -9903,7 +9945,7 @@ class WebRTCPhone extends Emitter {
9903
9945
  return false;
9904
9946
  }
9905
9947
 
9906
- logger$5.info('WebRTC hangup', { sipId: sipSession.id });
9948
+ logger$7.info('WebRTC hangup', { sipId: sipSession.id });
9907
9949
 
9908
9950
  const sipSessionId = this.getSipSessionId(sipSession);
9909
9951
 
@@ -9949,7 +9991,7 @@ class WebRTCPhone extends Emitter {
9949
9991
  endCurrentCall(callSession ) {
9950
9992
  const isCurrent = this.isCurrentCallSipSession(callSession);
9951
9993
 
9952
- logger$5.info('Ending current call', {
9994
+ logger$7.info('Ending current call', {
9953
9995
  id: callSession ? callSession.getId() : null,
9954
9996
  isCurrent,
9955
9997
  });
@@ -9973,7 +10015,7 @@ class WebRTCPhone extends Emitter {
9973
10015
  }
9974
10016
 
9975
10017
  async close() {
9976
- logger$5.info('WebRTC close');
10018
+ logger$7.info('WebRTC close');
9977
10019
 
9978
10020
  try {
9979
10021
  await Promise.race([
@@ -9981,7 +10023,7 @@ class WebRTCPhone extends Emitter {
9981
10023
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9982
10024
  ]);
9983
10025
  } catch (e) {
9984
- logger$5.error('WebRTC close, unregister error', e);
10026
+ logger$7.error('WebRTC close, unregister error', e);
9985
10027
  }
9986
10028
 
9987
10029
  this.client.close();
@@ -9999,12 +10041,12 @@ class WebRTCPhone extends Emitter {
9999
10041
  }
10000
10042
 
10001
10043
  enableRinging() {
10002
- logger$5.info('WebRTC enable ringing');
10044
+ logger$7.info('WebRTC enable ringing');
10003
10045
  this.ringingEnabled = true;
10004
10046
  }
10005
10047
 
10006
10048
  disableRinging() {
10007
- logger$5.info('WebRTC disable ringing');
10049
+ logger$7.info('WebRTC disable ringing');
10008
10050
  this.ringingEnabled = false;
10009
10051
  }
10010
10052
 
@@ -10026,8 +10068,12 @@ class WebRTCPhone extends Emitter {
10026
10068
  }
10027
10069
 
10028
10070
  const sessionId = this.incomingSessions[0];
10071
+ const sipSession = this.client.getSipSession(sessionId);
10072
+ if (!sipSession) {
10073
+ return null;
10074
+ }
10029
10075
 
10030
- return this._createCallSession(this.client.getSipSession(sessionId));
10076
+ return this._createCallSession(sipSession);
10031
10077
  }
10032
10078
 
10033
10079
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -10044,7 +10090,7 @@ class WebRTCPhone extends Emitter {
10044
10090
 
10045
10091
  // Deprecated
10046
10092
  getLocalMediaStream(callSession ) {
10047
- logger$5.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10093
+ logger$7.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
10048
10094
  return this.getLocalStream(callSession);
10049
10095
  }
10050
10096
 
@@ -10086,7 +10132,7 @@ class WebRTCPhone extends Emitter {
10086
10132
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
10087
10133
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
10088
10134
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
10089
- logger$5.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10135
+ logger$7.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
10090
10136
 
10091
10137
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
10092
10138
  this.incomingSessions.push(callSession.getId());
@@ -10105,11 +10151,12 @@ class WebRTCPhone extends Emitter {
10105
10151
  callSession);
10106
10152
  }
10107
10153
 
10154
+ callSession.creationTime = new Date();
10108
10155
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
10109
10156
  });
10110
10157
 
10111
10158
  this.client.on(this.client.ON_REINVITE, (...args) => {
10112
- logger$5.info('WebRTC on reinvite', {
10159
+ logger$7.info('WebRTC on reinvite', {
10113
10160
  sessionId: args[0].id,
10114
10161
  inviteId: args[1].id,
10115
10162
  updatedCalleeName: args[2],
@@ -10129,7 +10176,7 @@ class WebRTCPhone extends Emitter {
10129
10176
  });
10130
10177
 
10131
10178
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
10132
- logger$5.info('WebRTC call accepted', { sipId: sipSession.id });
10179
+ logger$7.info('WebRTC call accepted', { sipId: sipSession.id });
10133
10180
 
10134
10181
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
10135
10182
 
@@ -10140,22 +10187,29 @@ class WebRTCPhone extends Emitter {
10140
10187
  this.client.on('ended', () => {});
10141
10188
 
10142
10189
  this.client.on(this.client.ON_ERROR, e => {
10143
- logger$5.error('WebRTC error', e);
10190
+ logger$7.error('WebRTC error', e);
10144
10191
  this.eventEmitter.emit(ON_CALL_ERROR, e);
10145
10192
  });
10146
10193
 
10194
+ this.client.on(this.client.REJECTED, session => {
10195
+ logger$7.info('WebRTC call rejected', session.id);
10196
+ const callSession = this._createCallSession(session);
10197
+ callSession.endTime = new Date();
10198
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
10199
+ });
10200
+
10147
10201
  this.client.on(this.client.UNREGISTERED, () => {
10148
- logger$5.info('WebRTC unregistered');
10202
+ logger$7.info('WebRTC unregistered');
10149
10203
  this.eventEmitter.emit(ON_UNREGISTERED);
10150
10204
  });
10151
10205
 
10152
10206
  this.client.on(this.client.ON_DISCONNECTED, () => {
10153
- logger$5.info('WebRTC disconnected');
10154
- this.eventEmitter.emit(ON_DISCONNECTED$1);
10207
+ logger$7.info('WebRTC disconnected');
10208
+ this.eventEmitter.emit(ON_DISCONNECTED);
10155
10209
  });
10156
10210
 
10157
10211
  this.client.on(this.client.REGISTERED, () => {
10158
- logger$5.info('WebRTC registered', {
10212
+ logger$7.info('WebRTC registered', {
10159
10213
  shouldSendReinvite: this.shouldSendReinvite,
10160
10214
  state: this.currentSipSession ? this.currentSipSession.state : null,
10161
10215
  currentSipSession: !!this.currentSipSession,
@@ -10176,19 +10230,19 @@ class WebRTCPhone extends Emitter {
10176
10230
  // Send reinvite with iceRestart
10177
10231
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
10178
10232
  } catch (e) {
10179
- logger$5.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10233
+ logger$7.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
10180
10234
  }
10181
10235
  }
10182
10236
  });
10183
10237
 
10184
10238
  this.client.on(this.client.CONNECTED, () => {
10185
- logger$5.info('WebRTC client connected');
10239
+ logger$7.info('WebRTC client connected');
10186
10240
 
10187
10241
  this.stopHeartbeat();
10188
10242
  });
10189
10243
 
10190
10244
  this.client.on(this.client.DISCONNECTED, () => {
10191
- logger$5.info('WebRTC client disconnected');
10245
+ logger$7.info('WebRTC client disconnected');
10192
10246
 
10193
10247
  this.eventEmitter.emit(ON_UNREGISTERED);
10194
10248
 
@@ -10202,7 +10256,7 @@ class WebRTCPhone extends Emitter {
10202
10256
  });
10203
10257
 
10204
10258
  this.client.on(this.client.ON_TRACK, (session, event) => {
10205
- this.eventEmitter.emit(ON_TRACK$1, session, event);
10259
+ this.eventEmitter.emit(ON_TRACK, session, event);
10206
10260
  });
10207
10261
 
10208
10262
  this.client.on('onVideoInputChange', stream => {
@@ -10217,7 +10271,7 @@ class WebRTCPhone extends Emitter {
10217
10271
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
10218
10272
  const callSession = this.getCallSession(this.getSipSessionId(session));
10219
10273
 
10220
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
10274
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
10221
10275
  });
10222
10276
 
10223
10277
  // Used when upgrading directly in screenshare mode
@@ -10226,7 +10280,7 @@ class WebRTCPhone extends Emitter {
10226
10280
  const localStream = this.client.getLocalStream(sipSessionId);
10227
10281
  const callSession = this.callSessions[sipSessionId];
10228
10282
 
10229
- logger$5.info('Updrading directly in screensharing mode', {
10283
+ logger$7.info('Updrading directly in screensharing mode', {
10230
10284
  sipSessionId,
10231
10285
  tracks: localStream ? localStream.getTracks() : null,
10232
10286
  });
@@ -10356,6 +10410,7 @@ class WebRTCPhone extends Emitter {
10356
10410
  const number = identity ? identity.uri._normal.user : null;
10357
10411
  const { state } = sipSession || {};
10358
10412
  const sessionId = this.getSipSessionId(sipSession);
10413
+ fromSession = fromSession || this.callSessions[sessionId];
10359
10414
 
10360
10415
  const callSession = new CallSession({
10361
10416
  callId: fromSession && fromSession.callId,
@@ -10363,6 +10418,8 @@ class WebRTCPhone extends Emitter {
10363
10418
  sipStatus: state,
10364
10419
  displayName: identity ? identity.displayName || number : number,
10365
10420
  startTime: fromSession ? fromSession.startTime : new Date(),
10421
+ creationTime: fromSession ? fromSession.creationTime : null,
10422
+ endTime: fromSession ? fromSession.endTime : null,
10366
10423
  answered: state === sessionState.SessionState.Established,
10367
10424
  paused: this.client.isCallHeld(sipSession),
10368
10425
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10373,6 +10430,7 @@ class WebRTCPhone extends Emitter {
10373
10430
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10374
10431
  recording: fromSession ? fromSession.isRecording() : false,
10375
10432
  recordingPaused: false, // @TODO
10433
+ sipSession,
10376
10434
  ...extra,
10377
10435
  });
10378
10436
 
@@ -10401,11 +10459,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10401
10459
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10402
10460
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10403
10461
  ON_CALL_FAILED: ON_CALL_FAILED,
10462
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10404
10463
  ON_CALL_ENDED: ON_CALL_ENDED,
10405
10464
  ON_CALL_ENDING: ON_CALL_ENDING,
10406
10465
  ON_MESSAGE: ON_MESSAGE,
10407
- ON_REINVITE: ON_REINVITE$1,
10408
- ON_TRACK: ON_TRACK$1,
10466
+ ON_REINVITE: ON_REINVITE,
10467
+ ON_TRACK: ON_TRACK,
10409
10468
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10410
10469
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10411
10470
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10420,16 +10479,24 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10420
10479
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10421
10480
  ON_CALL_ERROR: ON_CALL_ERROR,
10422
10481
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10423
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10482
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10424
10483
  ON_CHAT: ON_CHAT,
10425
10484
  ON_SIGNAL: ON_SIGNAL,
10426
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10485
+ ON_DISCONNECTED: ON_DISCONNECTED,
10427
10486
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10428
10487
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10429
- events: events$1,
10488
+ events: events,
10430
10489
  'default': WebRTCPhone
10431
10490
  });
10432
10491
 
10492
+ /* */
10493
+ class SFUNotAvailableError extends Error {
10494
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10495
+ super(message);
10496
+ this.name = 'SFUNotAvailableError';
10497
+ }
10498
+ }
10499
+
10433
10500
  //
10434
10501
 
10435
10502
  const logger$6 = IssueReporter$1.loggerFor('simple-phone');
@@ -10814,13 +10881,13 @@ class Phone extends Emitter {
10814
10881
 
10815
10882
  checkSfu() {
10816
10883
  if (!this.hasSfu()) {
10817
- throw new Error('Sorry your user is not configured to support video conference');
10884
+ throw new SFUNotAvailableError();
10818
10885
  }
10819
10886
  }
10820
10887
 
10821
10888
  _transferEvents() {
10822
10889
  this.unbind();
10823
- [...events, ...transportEvents].forEach(event => {
10890
+ [...events$1, ...transportEvents].forEach(event => {
10824
10891
  this.client.on(event, (...args) =>
10825
10892
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10826
10893
  });
@@ -10842,7 +10909,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10842
10909
 
10843
10910
  //
10844
10911
 
10845
- const SOCKET_EVENTS = {
10912
+ const SOCKET_EVENTS$1 = {
10846
10913
  ON_OPEN: 'onopen',
10847
10914
  ON_MESSAGE: 'onmessage',
10848
10915
  ON_ERROR: 'onerror',
@@ -10938,7 +11005,7 @@ const BLACKLIST_EVENTS = [
10938
11005
  ];
10939
11006
 
10940
11007
  const HEARTBEAT_ENGINE_VERSION = '20.09';
10941
- const logger$7 = IssueReporter$1.loggerFor('wazo-ws');
11008
+ const logger$5 = IssueReporter$1.loggerFor('wazo-ws');
10942
11009
  const messageLogger = IssueReporter$1.loggerFor('wazo-ws-message');
10943
11010
 
10944
11011
  class WebSocketClient extends Emitter {
@@ -10987,24 +11054,24 @@ class WebSocketClient extends Emitter {
10987
11054
  }
10988
11055
 
10989
11056
  connect() {
10990
- logger$7.info('connect method started', { host: this.host, token: this.token });
11057
+ logger$5.info('connect method started', { host: this.host, token: this.token });
10991
11058
  this.socket = new ReconnectingWebSocket__default['default'](this._getUrl.bind(this), [], this.options);
10992
11059
  if (this.options.binaryType) {
10993
11060
  this.socket.binaryType = this.options.binaryType;
10994
11061
  }
10995
11062
 
10996
11063
  this.socket.onopen = () => {
10997
- logger$7.info('on Wazo WS open', { method: 'connect', host: this.host });
10998
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
11064
+ logger$5.info('on Wazo WS open', { method: 'connect', host: this.host });
11065
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10999
11066
  };
11000
11067
 
11001
11068
  this.socket.onerror = event => {
11002
- logger$7.error('on Wazo WS error', event.target);
11003
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
11069
+ logger$5.error('on Wazo WS error', event.target);
11070
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
11004
11071
  };
11005
11072
 
11006
11073
  this.socket.onmessage = (event ) => {
11007
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
11074
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
11008
11075
 
11009
11076
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
11010
11077
  let { name } = message;
@@ -11029,7 +11096,7 @@ class WebSocketClient extends Emitter {
11029
11096
 
11030
11097
  this.socket.onclose = event => {
11031
11098
  // Can't be converted to JSON (circular structure)
11032
- logger$7.info('on Wazo WS close', {
11099
+ logger$5.info('on Wazo WS close', {
11033
11100
  reason: event.reason,
11034
11101
  code: event.code,
11035
11102
  readyState: event.target.readyState,
@@ -11037,22 +11104,22 @@ class WebSocketClient extends Emitter {
11037
11104
  token: this.token,
11038
11105
  });
11039
11106
  this.initialized = false;
11040
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
11107
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
11041
11108
 
11042
11109
  switch (event.code) {
11043
11110
  case 4002:
11044
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
11111
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
11045
11112
  break;
11046
11113
  }
11047
11114
  };
11048
11115
 
11049
11116
  this.socket.onerror = event => {
11050
- logger$7.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11117
+ logger$5.info('Wazo WS error', { message: event.message, code: event.code, readyState: event.target.readyState });
11051
11118
  };
11052
11119
  }
11053
11120
 
11054
11121
  close(force = false) {
11055
- logger$7.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11122
+ logger$5.info('Wazo WS close', { socket: !!this.socket, host: this.host, token: this.token });
11056
11123
 
11057
11124
  if (!this.socket) {
11058
11125
  return;
@@ -11070,7 +11137,7 @@ class WebSocketClient extends Emitter {
11070
11137
 
11071
11138
  updateToken(token ) {
11072
11139
  this.token = token;
11073
- logger$7.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11140
+ logger$5.info('Wazo WS updating token', { url: this._getUrl(), token, socket: !!this.socket });
11074
11141
 
11075
11142
  if (this.socket) {
11076
11143
  // If still connected, send the token to the WS
@@ -11088,7 +11155,7 @@ class WebSocketClient extends Emitter {
11088
11155
  }
11089
11156
 
11090
11157
  startHeartbeat() {
11091
- logger$7.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11158
+ logger$5.info('Wazo WS start heartbeat', { host: this.host, token: this.token });
11092
11159
 
11093
11160
  if (!this.socket) {
11094
11161
  this.heartbeat.stop();
@@ -11102,7 +11169,7 @@ class WebSocketClient extends Emitter {
11102
11169
  }
11103
11170
 
11104
11171
  stopHeartbeat() {
11105
- logger$7.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11172
+ logger$5.info('Wazo WS stop heartbeat', { host: this.host, token: this.token });
11106
11173
 
11107
11174
  this.heartbeat.stop();
11108
11175
  }
@@ -11132,7 +11199,7 @@ class WebSocketClient extends Emitter {
11132
11199
  }
11133
11200
 
11134
11201
  reconnect(reason ) {
11135
- logger$7.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11202
+ logger$5.info('Wazo WS reconnect', { reason, socket: !!this.socket, host: this.host, token: this.token });
11136
11203
  if (!this.socket) {
11137
11204
  return;
11138
11205
  }
@@ -11157,7 +11224,7 @@ class WebSocketClient extends Emitter {
11157
11224
  break;
11158
11225
  case 'start':
11159
11226
  this.initialized = true;
11160
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
11227
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
11161
11228
  break;
11162
11229
  default:
11163
11230
  this.eventEmitter.emit('message', message);
@@ -11188,7 +11255,7 @@ class WebSocketClient extends Emitter {
11188
11255
  this.close();
11189
11256
  }
11190
11257
  const url = `wss://${this.host || ''}/api/websocketd/?token=${this.token || ''}&version=${this.version}`;
11191
- logger$7.log('Wazo WS url computed to reconnect', { url });
11258
+ logger$5.log('Wazo WS url computed to reconnect', { url });
11192
11259
 
11193
11260
  return url;
11194
11261
  }
@@ -11196,15 +11263,15 @@ class WebSocketClient extends Emitter {
11196
11263
  _onHeartbeat(message ) {
11197
11264
  if (message.payload === 'pong') {
11198
11265
  this.heartbeat.onHeartbeat();
11199
- logger$7.log('on heartbeat received from Wazo WS');
11266
+ logger$5.log('on heartbeat received from Wazo WS');
11200
11267
  }
11201
11268
  }
11202
11269
 
11203
11270
  async _onHeartbeatTimeout() {
11204
- logger$7.log('heartbeat timed out', { host: this.host, token: this.token });
11271
+ logger$5.log('heartbeat timed out', { host: this.host, token: this.token });
11205
11272
 
11206
11273
  this.close();
11207
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
11274
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
11208
11275
 
11209
11276
  if (this.onHeartBeatTimeout) {
11210
11277
  this.onHeartBeatTimeout();
@@ -11284,7 +11351,7 @@ WebSocketClient.eventLists = [
11284
11351
 
11285
11352
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11286
11353
  __proto__: null,
11287
- SOCKET_EVENTS: SOCKET_EVENTS,
11354
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
11288
11355
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11289
11356
  FAVORITE_ADDED: FAVORITE_ADDED,
11290
11357
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11357,10 +11424,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11357
11424
 
11358
11425
  //
11359
11426
 
11360
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11361
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11427
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11428
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11362
11429
 
11363
- const logger$8 = IssueReporter$1.loggerFor('simple-ws-client');
11430
+ const logger$4 = IssueReporter$1.loggerFor('simple-ws-client');
11364
11431
 
11365
11432
  class Websocket extends Emitter {
11366
11433
 
@@ -11374,9 +11441,9 @@ class Websocket extends Emitter {
11374
11441
  // $FlowFixMe
11375
11442
  this[key] = OTHER_EVENTS[key];
11376
11443
  });
11377
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
11444
+ Object.keys(SOCKET_EVENTS).forEach(key => {
11378
11445
  // $FlowFixMe
11379
- this[key] = SOCKET_EVENTS$1[key];
11446
+ this[key] = SOCKET_EVENTS[key];
11380
11447
  });
11381
11448
  this.eventLists = WebSocketClient.eventLists;
11382
11449
 
@@ -11384,7 +11451,7 @@ class Websocket extends Emitter {
11384
11451
  }
11385
11452
 
11386
11453
  open(host , session ) {
11387
- logger$8.info('open simple WebSocket', { host, token: session.token });
11454
+ logger$4.info('open simple WebSocket', { host, token: session.token });
11388
11455
  this.ws = new WebSocketClient(
11389
11456
  {
11390
11457
  host,
@@ -11412,7 +11479,7 @@ class Websocket extends Emitter {
11412
11479
  }
11413
11480
 
11414
11481
  updateToken(token ) {
11415
- logger$8.info('update token via simple Websocket', { token, ws: !!this.ws });
11482
+ logger$4.info('update token via simple Websocket', { token, ws: !!this.ws });
11416
11483
 
11417
11484
  if (!this.ws) {
11418
11485
  return;
@@ -11440,7 +11507,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11440
11507
 
11441
11508
  //
11442
11509
 
11443
- const logger$9 = IssueReporter$1.loggerFor('room');
11510
+ const logger$3 = IssueReporter$1.loggerFor('room');
11444
11511
 
11445
11512
  class Participant extends Emitter {
11446
11513
 
@@ -11562,7 +11629,7 @@ class Participant extends Emitter {
11562
11629
  }
11563
11630
 
11564
11631
  onTalking(isTalking ) {
11565
- logger$9.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11632
+ logger$3.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11566
11633
  this.isTalking = isTalking;
11567
11634
  // you may notice we're not broadcasting: since all participants are getting this info
11568
11635
  // directly from asterisk, there's no need to do so
@@ -11665,7 +11732,7 @@ class Participant extends Emitter {
11665
11732
  }
11666
11733
 
11667
11734
  updateStatus(status , broadcast = true) {
11668
- logger$9.info('updating participant status', { name: this.name, status });
11735
+ logger$3.info('updating participant status', { name: this.name, status });
11669
11736
 
11670
11737
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11671
11738
  if (status.audioMuted) {
@@ -11713,7 +11780,7 @@ class Participant extends Emitter {
11713
11780
 
11714
11781
  broadcastStatus(inboundStatus = null) {
11715
11782
  const status = inboundStatus || this.getStatus();
11716
- logger$9.info('broadcasting participant status', { callId: this.callId, status });
11783
+ logger$3.info('broadcasting participant status', { callId: this.callId, status });
11717
11784
 
11718
11785
  this.room.sendSignal({
11719
11786
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11749,9 +11816,9 @@ class LocalParticipant extends Participant {
11749
11816
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11750
11817
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11751
11818
 
11752
- const logger$a = IssueReporter$1.loggerFor('sdk-room');
11819
+ const logger$2 = IssueReporter$1.loggerFor('sdk-room');
11753
11820
 
11754
- class Room extends Emitter {
11821
+ class Room$1 extends Emitter {
11755
11822
 
11756
11823
 
11757
11824
 
@@ -11809,7 +11876,7 @@ class Room extends Emitter {
11809
11876
  extra = {},
11810
11877
  ) {
11811
11878
  super();
11812
- logger$a.info('room initialized', { callId, extension, sourceId, meetingUuid });
11879
+ logger$2.info('room initialized', { callId, extension, sourceId, meetingUuid });
11813
11880
 
11814
11881
  // Represents the room callSession
11815
11882
  this.callSession = callSession;
@@ -11875,7 +11942,7 @@ class Room extends Emitter {
11875
11942
  * @returns {Promise<Room>}
11876
11943
  */
11877
11944
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11878
- logger$a.info('connecting to room', { extension, audioOnly, room: !!room });
11945
+ logger$2.info('connecting to room', { extension, audioOnly, room: !!room });
11879
11946
 
11880
11947
  if (!room) {
11881
11948
  await Wazo.Phone.connect();
@@ -11888,7 +11955,7 @@ class Room extends Emitter {
11888
11955
 
11889
11956
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11890
11957
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11891
- logger$a.info('room call received via WS', { callId: data.call_id });
11958
+ logger$2.info('room call received via WS', { callId: data.call_id });
11892
11959
  if (room) {
11893
11960
  room.setCallId(data.call_id);
11894
11961
  }
@@ -11896,7 +11963,7 @@ class Room extends Emitter {
11896
11963
 
11897
11964
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11898
11965
  // eslint-disable-next-line no-param-reassign
11899
- room = new Room(callSession, extension, null, null, extra);
11966
+ room = new Room$1(callSession, extension, null, null, extra);
11900
11967
 
11901
11968
  // Wait for the call to be accepted
11902
11969
  await new Promise((resolve, reject) => {
@@ -11917,7 +11984,7 @@ class Room extends Emitter {
11917
11984
  // Retrieve conference
11918
11985
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11919
11986
 
11920
- logger$a.info('connected to room', {
11987
+ logger$2.info('connected to room', {
11921
11988
  sourceId: conference ? conference.sourceId : null,
11922
11989
  name: conference ? conference.name : null,
11923
11990
  });
@@ -11927,7 +11994,7 @@ class Room extends Emitter {
11927
11994
  room.setName(conference.name);
11928
11995
  }
11929
11996
  } else if (meeting) {
11930
- logger$a.info('Already connected to meeting', {
11997
+ logger$2.info('Already connected to meeting', {
11931
11998
  uuid: meeting.uuid,
11932
11999
  name: meeting.name,
11933
12000
  });
@@ -11940,13 +12007,13 @@ class Room extends Emitter {
11940
12007
  }
11941
12008
 
11942
12009
  static disconnect() {
11943
- logger$a.info('static disconnection to room');
12010
+ logger$2.info('static disconnection to room');
11944
12011
 
11945
12012
  Wazo.Phone.disconnect();
11946
12013
  }
11947
12014
 
11948
12015
  async disconnect() {
11949
- logger$a.info('disconnection to room called');
12016
+ logger$2.info('disconnection to room called');
11950
12017
 
11951
12018
  await Wazo.Phone.hangup(this.callSession);
11952
12019
  this.callSession = null;
@@ -11966,19 +12033,19 @@ class Room extends Emitter {
11966
12033
  }
11967
12034
 
11968
12035
  setSourceId(sourceId ) {
11969
- logger$a.info('set room source id', { sourceId });
12036
+ logger$2.info('set room source id', { sourceId });
11970
12037
 
11971
12038
  this.sourceId = sourceId;
11972
12039
  }
11973
12040
 
11974
12041
  setMeetingUuid(meetingUuid ) {
11975
- logger$a.info('set meeting uuid', { meetingUuid });
12042
+ logger$2.info('set meeting uuid', { meetingUuid });
11976
12043
 
11977
12044
  this.meetingUuid = meetingUuid;
11978
12045
  }
11979
12046
 
11980
12047
  setCallId(callId ) {
11981
- logger$a.info('set room call id', { callId });
12048
+ logger$2.info('set room call id', { callId });
11982
12049
 
11983
12050
  if (callId) {
11984
12051
  this.callId = callId;
@@ -11986,7 +12053,7 @@ class Room extends Emitter {
11986
12053
  }
11987
12054
 
11988
12055
  setName(name ) {
11989
- logger$a.info('set room name', { name });
12056
+ logger$2.info('set room name', { name });
11990
12057
 
11991
12058
  this.name = name;
11992
12059
  }
@@ -12005,7 +12072,7 @@ class Room extends Emitter {
12005
12072
  }
12006
12073
 
12007
12074
  async startScreenSharing(constraints ) {
12008
- logger$a.info('start room screen sharing', { constraints });
12075
+ logger$2.info('start room screen sharing', { constraints });
12009
12076
 
12010
12077
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
12011
12078
  if (!screensharingStream) {
@@ -12019,7 +12086,7 @@ class Room extends Emitter {
12019
12086
  }
12020
12087
 
12021
12088
  async stopScreenSharing(restoreLocalStream = true) {
12022
- logger$a.info('stop room screen sharing');
12089
+ logger$2.info('stop room screen sharing');
12023
12090
 
12024
12091
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
12025
12092
 
@@ -12031,7 +12098,7 @@ class Room extends Emitter {
12031
12098
  }
12032
12099
 
12033
12100
  turnCameraOff() {
12034
- logger$a.info('turn room camera off');
12101
+ logger$2.info('turn room camera off');
12035
12102
 
12036
12103
  Wazo.Phone.turnCameraOff(this.callSession);
12037
12104
 
@@ -12041,7 +12108,7 @@ class Room extends Emitter {
12041
12108
  }
12042
12109
 
12043
12110
  turnCameraOn() {
12044
- logger$a.info('turn room camera on');
12111
+ logger$2.info('turn room camera on');
12045
12112
 
12046
12113
  Wazo.Phone.turnCameraOn(this.callSession);
12047
12114
 
@@ -12051,7 +12118,7 @@ class Room extends Emitter {
12051
12118
  }
12052
12119
 
12053
12120
  mute() {
12054
- logger$a.info('mute room');
12121
+ logger$2.info('mute room');
12055
12122
 
12056
12123
  Wazo.Phone.mute(this.callSession);
12057
12124
 
@@ -12059,7 +12126,7 @@ class Room extends Emitter {
12059
12126
  }
12060
12127
 
12061
12128
  unmute() {
12062
- logger$a.info('unmute room');
12129
+ logger$2.info('unmute room');
12063
12130
 
12064
12131
  Wazo.Phone.unmute(this.callSession);
12065
12132
 
@@ -12079,7 +12146,7 @@ class Room extends Emitter {
12079
12146
  }
12080
12147
 
12081
12148
  hold() {
12082
- logger$a.info('hold room');
12149
+ logger$2.info('hold room');
12083
12150
 
12084
12151
  Wazo.Phone.hold(this.callSession, true);
12085
12152
 
@@ -12089,7 +12156,7 @@ class Room extends Emitter {
12089
12156
  }
12090
12157
 
12091
12158
  async resume() {
12092
- logger$a.info('resume room');
12159
+ logger$2.info('resume room');
12093
12160
 
12094
12161
  const newStream = await Wazo.Phone.resume(this.callSession, true);
12095
12162
 
@@ -12117,13 +12184,13 @@ class Room extends Emitter {
12117
12184
  }
12118
12185
 
12119
12186
  sendDTMF(tone ) {
12120
- logger$a.info('send room DTMF', { tone });
12187
+ logger$2.info('send room DTMF', { tone });
12121
12188
 
12122
12189
  Wazo.Phone.sendDTMF(tone, this.callSession);
12123
12190
  }
12124
12191
 
12125
12192
  async sendReinvite(newConstraints = null) {
12126
- logger$a.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
12193
+ logger$2.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
12127
12194
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
12128
12195
 
12129
12196
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -12182,7 +12249,7 @@ class Room extends Emitter {
12182
12249
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
12183
12250
 
12184
12251
  this.on(this.ON_AUDIO_STREAM, stream => {
12185
- logger$a.info('on room audio stream');
12252
+ logger$2.info('on room audio stream');
12186
12253
 
12187
12254
  this.audioStream = stream;
12188
12255
  if (!this.roomAudioElement) {
@@ -12195,7 +12262,7 @@ class Room extends Emitter {
12195
12262
  });
12196
12263
 
12197
12264
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
12198
- logger$a.info('on room video stream', { streamId });
12265
+ logger$2.info('on room video stream', { streamId });
12199
12266
 
12200
12267
  this._mapMsid(sipSession.body.body);
12201
12268
 
@@ -12210,7 +12277,7 @@ class Room extends Emitter {
12210
12277
  });
12211
12278
 
12212
12279
  this.on(this.ON_REMOVE_STREAM, stream => {
12213
- logger$a.info('on room remove stream');
12280
+ logger$2.info('on room remove stream');
12214
12281
 
12215
12282
  const participant = this.participants.find(someParticipant =>
12216
12283
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -12342,7 +12409,7 @@ class Room extends Emitter {
12342
12409
  const requester = this._getParticipantFromCallId(origin.callId);
12343
12410
  if (requester) {
12344
12411
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
12345
- logger$a.info('trigger room requester status', { origin });
12412
+ logger$2.info('trigger room requester status', { origin });
12346
12413
  requester.triggerUpdate('REQUESTER_UPDATE');
12347
12414
  }
12348
12415
  break;
@@ -12373,24 +12440,24 @@ class Room extends Emitter {
12373
12440
 
12374
12441
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
12375
12442
  if (participant.user_uuid === session.uuid) {
12376
- logger$a.info('room current user joined');
12443
+ logger$2.info('room current user joined');
12377
12444
 
12378
12445
  // Retrieve participants via an API calls
12379
12446
  const conferenceId = this.sourceId || payload.data.conference_id;
12380
12447
  let response;
12381
12448
  try {
12382
12449
  if (this.meetingUuid) {
12383
- logger$a.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12450
+ logger$2.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12384
12451
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
12385
12452
  } else {
12386
- logger$a.info('fetching conference participants', { conferenceId });
12453
+ logger$2.info('fetching conference participants', { conferenceId });
12387
12454
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
12388
12455
  }
12389
12456
  } catch (e) {
12390
- logger$a.error('room participants fetching, error', e);
12457
+ logger$2.error('room participants fetching, error', e);
12391
12458
  }
12392
12459
  if (response) {
12393
- logger$a.info('conference participants fetched', { nb: response.items.length });
12460
+ logger$2.info('conference participants fetched', { nb: response.items.length });
12394
12461
  participants = response.items.map(item => {
12395
12462
  const isMe = item.call_id === this.callId;
12396
12463
 
@@ -12417,7 +12484,7 @@ class Room extends Emitter {
12417
12484
  ? new Wazo.RemoteParticipant(this, participant)
12418
12485
  : null;
12419
12486
 
12420
- logger$a.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12487
+ logger$2.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12421
12488
 
12422
12489
  if (remoteParticipant) {
12423
12490
  this.participants.push(remoteParticipant);
@@ -12582,12 +12649,12 @@ class Room extends Emitter {
12582
12649
 
12583
12650
  //
12584
12651
 
12585
- const logger$b = IssueReporter$1.loggerFor('sdk-sip-room');
12652
+ const logger$1 = IssueReporter$1.loggerFor('sdk-sip-room');
12586
12653
 
12587
- class SipRoom extends Room {
12654
+ class SipRoom extends Room$1 {
12588
12655
 
12589
12656
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12590
- logger$b.info('connecting to sip room', { extension, audioOnly, room: !!room });
12657
+ logger$1.info('connecting to sip room', { extension, audioOnly, room: !!room });
12591
12658
 
12592
12659
  if (!room) {
12593
12660
  await Wazo.Phone.connect();
@@ -12603,7 +12670,7 @@ class SipRoom extends Room {
12603
12670
  room.setCallId(room.callSession.call.id);
12604
12671
  }
12605
12672
 
12606
- logger$b.info('connected to room', {
12673
+ logger$1.info('connected to room', {
12607
12674
  extension: room.extension,
12608
12675
  });
12609
12676
 
@@ -12611,7 +12678,7 @@ class SipRoom extends Room {
12611
12678
  }
12612
12679
 
12613
12680
  mute() {
12614
- logger$b.info('mute sip room');
12681
+ logger$1.info('mute sip room');
12615
12682
 
12616
12683
  Wazo.Phone.mute(this.callSession, false);
12617
12684
 
@@ -12619,7 +12686,7 @@ class SipRoom extends Room {
12619
12686
  }
12620
12687
 
12621
12688
  unmute() {
12622
- logger$b.info('unmute sip room');
12689
+ logger$1.info('unmute sip room');
12623
12690
 
12624
12691
  Wazo.Phone.unmute(this.callSession, false);
12625
12692
 
@@ -12887,7 +12954,7 @@ class NotificationOptions {
12887
12954
 
12888
12955
 
12889
12956
  // Represents a conference room, like `9000`.
12890
- class Room$1 {
12957
+ class Room {
12891
12958
 
12892
12959
 
12893
12960
 
@@ -12908,7 +12975,7 @@ class Room$1 {
12908
12975
  }
12909
12976
 
12910
12977
  connect(callSession ) {
12911
- return new Room$1({ ...this, connectedCallSession: callSession });
12978
+ return new Room({ ...this, connectedCallSession: callSession });
12912
12979
  }
12913
12980
 
12914
12981
  has(callSession ) {
@@ -12917,7 +12984,7 @@ class Room$1 {
12917
12984
 
12918
12985
  addParticipant(uuid , extension , talking = null) {
12919
12986
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12920
- return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12987
+ return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12921
12988
  }
12922
12989
 
12923
12990
  return this;
@@ -12936,7 +13003,7 @@ class Room$1 {
12936
13003
  updatedParticipants.push(participant);
12937
13004
  }
12938
13005
 
12939
- return new Room$1({ ...this, participants: updatedParticipants });
13006
+ return new Room({ ...this, participants: updatedParticipants });
12940
13007
  }
12941
13008
 
12942
13009
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12952,7 +13019,7 @@ class Room$1 {
12952
13019
  updatedParticipants.push(participant);
12953
13020
  }
12954
13021
 
12955
- return new Room$1({ ...this, participants: updatedParticipants });
13022
+ return new Room({ ...this, participants: updatedParticipants });
12956
13023
  }
12957
13024
 
12958
13025
  hasCallWithId(id ) {
@@ -12960,18 +13027,18 @@ class Room$1 {
12960
13027
  }
12961
13028
 
12962
13029
  disconnect() {
12963
- return new Room$1({ ...this, connectedCallSession: null });
13030
+ return new Room({ ...this, connectedCallSession: null });
12964
13031
  }
12965
13032
 
12966
13033
  removeParticipantWithUUID(uuid ) {
12967
- return new Room$1({
13034
+ return new Room({
12968
13035
  ...this,
12969
13036
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12970
13037
  });
12971
13038
  }
12972
13039
 
12973
13040
  removeParticipantWithExtension(extension ) {
12974
- return new Room$1({
13041
+ return new Room({
12975
13042
  ...this,
12976
13043
  participants: this.participants.filter(participant => participant.extension !== extension),
12977
13044
  });
@@ -12982,7 +13049,7 @@ class Room$1 {
12982
13049
  }
12983
13050
 
12984
13051
  static newFrom(room ) {
12985
- return newFrom(room, Room$1);
13052
+ return newFrom(room, Room);
12986
13053
  }
12987
13054
  }
12988
13055
 
@@ -13289,11 +13356,11 @@ var wazoWebsocket = {
13289
13356
  resolve();
13290
13357
  };
13291
13358
 
13292
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
13359
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
13293
13360
  handleError(`Connection error : ${error}`);
13294
13361
  });
13295
13362
 
13296
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
13363
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
13297
13364
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
13298
13365
  client.setOnHeartbeatTimeout(() => {
13299
13366
  handleError('No response to heartbeat');
@@ -13394,7 +13461,7 @@ var webrtc = {
13394
13461
  }),
13395
13462
  };
13396
13463
 
13397
- const parseCandidate$1 = line => {
13464
+ const parseCandidate = line => {
13398
13465
  let parts;
13399
13466
  // Parse both variants.
13400
13467
  if (line.indexOf('a=candidate:') === 0) {
@@ -13485,7 +13552,7 @@ var SymmetricNat = {
13485
13552
  }
13486
13553
 
13487
13554
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13488
- const cand = parseCandidate$1(e.candidate.candidate);
13555
+ const cand = parseCandidate(e.candidate.candidate);
13489
13556
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13490
13557
  candidates[cand.relatedPort].push(cand.port);
13491
13558
  } else if (!e.candidate) {
@@ -13553,7 +13620,7 @@ var iceIpv4 = {
13553
13620
  const rawCandidate = e.candidate.candidate;
13554
13621
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13555
13622
  hasSrflxOrRelay = true;
13556
- const candidate = parseCandidate$1(e.candidate.candidate);
13623
+ const candidate = parseCandidate(e.candidate.candidate);
13557
13624
  ips.push(candidate.ip);
13558
13625
  }
13559
13626
  } else if (!e.candidate) {
@@ -13590,7 +13657,7 @@ var checks = [
13590
13657
 
13591
13658
  //
13592
13659
 
13593
- const logger$c = IssueReporter$1.loggerFor('engine-check');
13660
+ const logger = IssueReporter$1.loggerFor('engine-check');
13594
13661
 
13595
13662
  class Checker {
13596
13663
 
@@ -13608,28 +13675,28 @@ class Checker {
13608
13675
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13609
13676
  await this._addEngineVersion();
13610
13677
 
13611
- logger$c.info('Engine check starting');
13678
+ logger.info('Engine check starting');
13612
13679
 
13613
13680
  for (let i = 0; i < this.checks.length; i++) {
13614
13681
  const { name, check } = this.checks[i];
13615
13682
 
13616
- logger$c.info(`Checking ${name} ...`);
13683
+ logger.info(`Checking ${name} ...`);
13617
13684
 
13618
13685
  onCheckBegin(name);
13619
13686
  try {
13620
13687
  // eslint-disable-next-line no-await-in-loop
13621
13688
  const result = await check(this.server, this.session, this.externalAppConfig);
13622
- logger$c.info(`Checking ${name} success.`, { result });
13689
+ logger.info(`Checking ${name} success.`, { result });
13623
13690
 
13624
13691
  onCheckResult(name, result);
13625
13692
  } catch (e) {
13626
- logger$c.info(`Checking ${name} failure`, { message: e.message });
13693
+ logger.info(`Checking ${name} failure`, { message: e.message });
13627
13694
 
13628
13695
  onCheckResult(name, e);
13629
13696
  }
13630
13697
  }
13631
13698
 
13632
- logger$c.info('Engine check done.');
13699
+ logger.info('Engine check done.');
13633
13700
  }
13634
13701
 
13635
13702
  addCheck(check ) {
@@ -13653,7 +13720,7 @@ const Wazo = {
13653
13720
  Auth: Auth$1,
13654
13721
  Phone: Phone$1,
13655
13722
  Websocket: Websocket$1,
13656
- Room,
13723
+ Room: Room$1,
13657
13724
  SipRoom,
13658
13725
  RemoteParticipant,
13659
13726
  LocalParticipant,
@@ -13686,7 +13753,7 @@ const Wazo = {
13686
13753
  Session,
13687
13754
  Voicemail,
13688
13755
  Relocation,
13689
- ConferenceRoom: Room$1,
13756
+ ConferenceRoom: Room,
13690
13757
  CallSession,
13691
13758
  IndirectTransfer,
13692
13759
  SwitchboardCall,
@@ -13711,6 +13778,7 @@ const Wazo = {
13711
13778
  InvalidSubscription,
13712
13779
  InvalidAuthorization,
13713
13780
  CanceledCallError,
13781
+ SFUNotAvailableError,
13714
13782
  };
13715
13783
 
13716
13784
  if (window) {