@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
@@ -1236,7 +1236,7 @@ class Contact {
1236
1236
  this[key] = old[key] || this[key];
1237
1237
  });
1238
1238
 
1239
- if (old.lineState && !this.lineState) {
1239
+ if (old.lineState) {
1240
1240
  this.lineState = old.lineState;
1241
1241
  }
1242
1242
 
@@ -1947,11 +1947,11 @@ var IssueReporter$1 = new IssueReporter();
1947
1947
 
1948
1948
  const methods = ['head', 'get', 'post', 'put', 'delete'];
1949
1949
 
1950
- const logger = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1950
+ const logger$c = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
1951
1951
 
1952
1952
  // Use a function here to be able to mock it in tests
1953
1953
  const realFetch = () => {
1954
- if (typeof document !== 'undefined') {
1954
+ if (typeof document !== 'undefined' && window.fetch) {
1955
1955
  // Browser
1956
1956
  return window.fetch;
1957
1957
  }
@@ -2086,7 +2086,7 @@ class ApiRequester {
2086
2086
  };
2087
2087
 
2088
2088
  if (this.refreshTokenPromise) {
2089
- logger.info('A token is already refreshing, waiting ...', { url });
2089
+ logger$c.info('A token is already refreshing, waiting ...', { url });
2090
2090
  await this.refreshTokenPromise;
2091
2091
  }
2092
2092
 
@@ -2106,7 +2106,7 @@ class ApiRequester {
2106
2106
  return promise.then(async (err ) => {
2107
2107
  // Check if the token is still valid
2108
2108
  if (firstCall && this._checkTokenExpired(response, err)) {
2109
- logger.warn('token expired', { error: err.reason });
2109
+ logger$c.warn('token expired', { error: err.reason });
2110
2110
  // Replay the call after refreshing the token
2111
2111
  return this._replayWithNewToken(err, path, method, body, headers, parse);
2112
2112
  }
@@ -2116,7 +2116,7 @@ class ApiRequester {
2116
2116
  : exceptionClass.fromResponse(err, response.status);
2117
2117
 
2118
2118
  if (this.shouldLogErrors) {
2119
- logger.error('API error', error);
2119
+ logger$c.error('API error', error);
2120
2120
  }
2121
2121
 
2122
2122
  throw error;
@@ -2126,7 +2126,7 @@ class ApiRequester {
2126
2126
  return newParse(response, isJson);
2127
2127
  }).catch(error => {
2128
2128
  if (this.shouldLogErrors) {
2129
- logger.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2129
+ logger$c.error('Fetch failed', { url, options, message: error.message, stack: error.stack });
2130
2130
  }
2131
2131
 
2132
2132
  throw error;
@@ -2154,13 +2154,13 @@ class ApiRequester {
2154
2154
  ) {
2155
2155
  const isTokenNotFound = this._isTokenNotFound(err);
2156
2156
  let newPath = path;
2157
- logger.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2157
+ logger$c.info('refreshing token', { inProgress: !!this.refreshTokenPromise });
2158
2158
 
2159
2159
  this.refreshTokenPromise = this.refreshTokenPromise || this.refreshTokenCallback();
2160
2160
 
2161
2161
  return this.refreshTokenPromise.then(() => {
2162
2162
  this.refreshTokenPromise = null;
2163
- logger.info('token refreshed', { isTokenNotFound });
2163
+ logger$c.info('token refreshed', { isTokenNotFound });
2164
2164
  if (isTokenNotFound) {
2165
2165
  const pathParts = path.split('/');
2166
2166
  pathParts.pop();
@@ -3253,8 +3253,10 @@ var updateFrom = (instance , from ) => {
3253
3253
 
3254
3254
 
3255
3255
 
3256
+
3256
3257
 
3257
3258
 
3259
+
3258
3260
 
3259
3261
 
3260
3262
 
@@ -3271,6 +3273,7 @@ var updateFrom = (instance , from ) => {
3271
3273
 
3272
3274
 
3273
3275
 
3276
+
3274
3277
 
3275
3278
 
3276
3279
  class CallSession {
@@ -3290,8 +3293,12 @@ class CallSession {
3290
3293
 
3291
3294
 
3292
3295
 
3296
+
3297
+
3293
3298
 
3294
3299
 
3300
+
3301
+
3295
3302
 
3296
3303
 
3297
3304
 
@@ -3329,6 +3336,8 @@ class CallSession {
3329
3336
 
3330
3337
 
3331
3338
 
3339
+
3340
+
3332
3341
 
3333
3342
  constructor({
3334
3343
  answered,
@@ -3342,6 +3351,8 @@ class CallSession {
3342
3351
  paused,
3343
3352
  ringing,
3344
3353
  startTime,
3354
+ creationTime,
3355
+ endTime,
3345
3356
  cameraEnabled,
3346
3357
  dialedExtension,
3347
3358
  sipCallId,
@@ -3354,12 +3365,15 @@ class CallSession {
3354
3365
  recording,
3355
3366
  recordingPaused,
3356
3367
  videoRemotelyDowngraded,
3368
+ sipSession,
3357
3369
  } ) {
3358
3370
  this.callId = callId;
3359
3371
  this.sipCallId = sipCallId;
3360
3372
  this.displayName = displayName;
3361
3373
  this.number = number;
3374
+ this.creationTime = creationTime;
3362
3375
  this.startTime = startTime;
3376
+ this.endTime = endTime;
3363
3377
  this.isCaller = isCaller;
3364
3378
  this.answered = answered;
3365
3379
  this.answeredBySystem = answeredBySystem;
@@ -3378,6 +3392,7 @@ class CallSession {
3378
3392
  this.recording = recording || false;
3379
3393
  this.recordingPaused = recordingPaused || false;
3380
3394
  this.videoRemotelyDowngraded = videoRemotelyDowngraded;
3395
+ this.sipSession = sipSession;
3381
3396
 
3382
3397
  // Useful to compare instead of instanceof with minified code
3383
3398
  this.type = 'CallSession';
@@ -4053,7 +4068,7 @@ const TRANSFER_FLOW_BLIND = 'blind';
4053
4068
 
4054
4069
  // const MINIMUM_WAZO_ENGINE_VERSION_FOR_CTI_HOLD = '20.11';
4055
4070
 
4056
- const logger$1 = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4071
+ const logger$b = IssueReporter$1 ? IssueReporter$1.loggerFor('cti-phone') : console;
4057
4072
 
4058
4073
  class CTIPhone extends Emitter {
4059
4074
 
@@ -4066,7 +4081,7 @@ class CTIPhone extends Emitter {
4066
4081
 
4067
4082
  constructor(session , isMobile = false, callbackAllLines = false) {
4068
4083
  super();
4069
- logger$1.info('CTI Phone created');
4084
+ logger$b.info('CTI Phone created');
4070
4085
  this.session = session;
4071
4086
  this.isMobile = isMobile;
4072
4087
  this.callbackAllLines = callbackAllLines;
@@ -4127,7 +4142,7 @@ class CTIPhone extends Emitter {
4127
4142
  }
4128
4143
 
4129
4144
  async makeCall(number , line ) {
4130
- logger$1.info('make CTI call', { number });
4145
+ logger$b.info('make CTI call', { number });
4131
4146
 
4132
4147
  if (!number) {
4133
4148
  return null;
@@ -4150,7 +4165,7 @@ class CTIPhone extends Emitter {
4150
4165
  if (!callSession) {
4151
4166
  return Promise.resolve(null);
4152
4167
  }
4153
- logger$1.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4168
+ logger$b.info('accept CTI call', { callId: callSession.getId(), number: callSession.number });
4154
4169
 
4155
4170
  if (!this.currentCall) {
4156
4171
  this.currentCall = callSession.call;
@@ -4163,7 +4178,7 @@ class CTIPhone extends Emitter {
4163
4178
  if (!callSession) {
4164
4179
  return;
4165
4180
  }
4166
- logger$1.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4181
+ logger$b.info('end current CTI call', { callId: callSession.getId(), number: callSession.number });
4167
4182
 
4168
4183
  this.currentCall = undefined;
4169
4184
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4173,7 +4188,7 @@ class CTIPhone extends Emitter {
4173
4188
  if (!callSession) {
4174
4189
  return Promise.resolve(false);
4175
4190
  }
4176
- logger$1.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4191
+ logger$b.info('hangup CTI call', { callId: callSession.getId(), number: callSession.number });
4177
4192
 
4178
4193
  try {
4179
4194
  await CallApi.cancelCall(callSession);
@@ -4184,7 +4199,7 @@ class CTIPhone extends Emitter {
4184
4199
  this.eventEmitter.emit('onCallEnded', callSession);
4185
4200
  return true;
4186
4201
  } catch (e) {
4187
- logger$1.error('hangup CTI call, error', e);
4202
+ logger$b.error('hangup CTI call, error', e);
4188
4203
 
4189
4204
  this.eventEmitter.emit('onCallFailed', callSession);
4190
4205
  return false;
@@ -4197,7 +4212,7 @@ class CTIPhone extends Emitter {
4197
4212
  if (!callSession) {
4198
4213
  return;
4199
4214
  }
4200
- logger$1.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4215
+ logger$b.info('reject CTI call', { callId: callSession.getId(), number: callSession.number });
4201
4216
 
4202
4217
  await CallApi.cancelCall(callSession);
4203
4218
  this.eventEmitter.emit('onCallEnded', callSession);
@@ -4207,7 +4222,7 @@ class CTIPhone extends Emitter {
4207
4222
  if (!callSession) {
4208
4223
  return;
4209
4224
  }
4210
- logger$1.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4225
+ logger$b.info('transfer CTI call', { callId: callSession.getId(), number: callSession.number, to: number });
4211
4226
 
4212
4227
  await CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_BLIND);
4213
4228
  }
@@ -4220,19 +4235,19 @@ class CTIPhone extends Emitter {
4220
4235
  if (!callSession) {
4221
4236
  return;
4222
4237
  }
4223
- logger$1.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4238
+ logger$b.info('indirect CTI transfer', { callId: callSession.getId(), number: callSession.number, to: number });
4224
4239
 
4225
4240
  return CallApi.transferCall(callSession.callId, number, TRANSFER_FLOW_ATTENDED);
4226
4241
  }
4227
4242
 
4228
4243
  async cancelCTIIndirectTransfer(transferId ) {
4229
- logger$1.info('cancel CTI transfer', { transferId });
4244
+ logger$b.info('cancel CTI transfer', { transferId });
4230
4245
 
4231
4246
  return CallApi.cancelCallTransfer(transferId);
4232
4247
  }
4233
4248
 
4234
4249
  async confirmCTIIndirectTransfer(transferId ) {
4235
- logger$1.info('confirm CTI transfer', { transferId });
4250
+ logger$b.info('confirm CTI transfer', { transferId });
4236
4251
 
4237
4252
  return CallApi.confirmCallTransfer(transferId);
4238
4253
  }
@@ -4241,19 +4256,19 @@ class CTIPhone extends Emitter {
4241
4256
  if (!callSession) {
4242
4257
  return;
4243
4258
  }
4244
- logger$1.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4259
+ logger$b.info('send CTI key', { callId: callSession.getId(), number: callSession.number, digits });
4245
4260
 
4246
4261
  return CallApi.sendDTMF(callSession.callId, digits);
4247
4262
  }
4248
4263
 
4249
4264
  onConnectionMade() {
4250
- logger$1.info('on CTI connection made');
4265
+ logger$b.info('on CTI connection made');
4251
4266
 
4252
4267
  this.eventEmitter.emit('onCallAccepted');
4253
4268
  }
4254
4269
 
4255
4270
  async close() {
4256
- logger$1.info('CTI close');
4271
+ logger$b.info('CTI close');
4257
4272
 
4258
4273
  return Promise.resolve();
4259
4274
  }
@@ -4262,7 +4277,7 @@ class CTIPhone extends Emitter {
4262
4277
  if (!callSession) {
4263
4278
  return;
4264
4279
  }
4265
- logger$1.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4280
+ logger$b.info('CTI hold', { callId: callSession.getId(), number: callSession.number });
4266
4281
 
4267
4282
  return CallApi.hold(callSession.callId);
4268
4283
  }
@@ -4271,7 +4286,7 @@ class CTIPhone extends Emitter {
4271
4286
  if (!callSession) {
4272
4287
  return;
4273
4288
  }
4274
- logger$1.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4289
+ logger$b.info('CTI resume', { callId: callSession.getId(), number: callSession.number });
4275
4290
 
4276
4291
  return CallApi.resume(callSession.callId);
4277
4292
  }
@@ -4280,7 +4295,7 @@ class CTIPhone extends Emitter {
4280
4295
  if (!callSession) {
4281
4296
  return;
4282
4297
  }
4283
- logger$1.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4298
+ logger$b.info('CTI mute', { callId: callSession.getId(), number: callSession.number });
4284
4299
 
4285
4300
  return CallApi.mute(callSession.callId);
4286
4301
  }
@@ -4289,7 +4304,7 @@ class CTIPhone extends Emitter {
4289
4304
  if (!callSession) {
4290
4305
  return;
4291
4306
  }
4292
- logger$1.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4307
+ logger$b.info('CTI unmute', { callId: callSession.getId(), number: callSession.number });
4293
4308
 
4294
4309
  return CallApi.unmute(callSession.callId);
4295
4310
  }
@@ -5298,7 +5313,7 @@ const AGENTD_VERSION = '1.0';
5298
5313
  const WEBHOOKD_VERSION = '1.0';
5299
5314
  const AMID_VERSION = '1.0';
5300
5315
 
5301
- const logger$2 = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5316
+ const logger$a = IssueReporter$1 ? IssueReporter$1.loggerFor('api') : console;
5302
5317
 
5303
5318
  class ApiClient {
5304
5319
 
@@ -5350,12 +5365,12 @@ class ApiClient {
5350
5365
  }
5351
5366
 
5352
5367
  async forceRefreshToken() {
5353
- logger$2.info('forcing refresh token, calling callback');
5368
+ logger$a.info('forcing refresh token, calling callback');
5354
5369
  return this.refreshTokenCallback();
5355
5370
  }
5356
5371
 
5357
5372
  async refreshTokenCallback() {
5358
- logger$2.info('refresh token callback called', {
5373
+ logger$a.info('refresh token callback called', {
5359
5374
  refreshToken: this.refreshToken,
5360
5375
  refreshBackend: this.refreshBackend,
5361
5376
  refreshExpiration: this.refreshExpiration,
@@ -5373,7 +5388,7 @@ class ApiClient {
5373
5388
  this.isMobile,
5374
5389
  );
5375
5390
 
5376
- logger$2.info('token refreshed', { token: session.token });
5391
+ logger$a.info('token refreshed', { token: session.token });
5377
5392
 
5378
5393
  if (this.onRefreshToken) {
5379
5394
  this.onRefreshToken(session.token, session);
@@ -5686,7 +5701,7 @@ class AdHocAPIConference {
5686
5701
 
5687
5702
  /* */
5688
5703
 
5689
- const parseCandidate = (candidate ) => {
5704
+ const parseCandidate$1 = (candidate ) => {
5690
5705
  if (!candidate) {
5691
5706
  return null;
5692
5707
  }
@@ -5798,11 +5813,16 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5798
5813
 
5799
5814
  // $FlowFixMe
5800
5815
  setRemoteSessionDescription(sessionDescription ) {
5801
- const result = super.setRemoteSessionDescription(sessionDescription);
5816
+ try {
5817
+ const result = super.setRemoteSessionDescription(sessionDescription);
5802
5818
 
5803
- this.eventEmitter.emit('setDescription', sessionDescription);
5819
+ this.eventEmitter.emit('setDescription', sessionDescription);
5804
5820
 
5805
- return result;
5821
+ return result;
5822
+ } catch (error) {
5823
+ this.logger.error('SessionDescriptionHandler.setRemoteSessionDescription error', error);
5824
+ throw error;
5825
+ }
5806
5826
  }
5807
5827
 
5808
5828
  // Overridden to avoid to fix ice-candidates missing in the SDP in react-native and chrome canary.
@@ -5840,7 +5860,7 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5840
5860
  this.peerConnectionDelegate.onicecandidate = event => {
5841
5861
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5842
5862
  if (event.candidate) {
5843
- this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
5863
+ this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5844
5864
  }
5845
5865
  };
5846
5866
 
@@ -6304,7 +6324,7 @@ const DEFAULT_ICE_TIMEOUT = 3000;
6304
6324
  const SEND_STATS_DELAY = 5000;
6305
6325
 
6306
6326
  const states = ['STATUS_NULL', 'STATUS_NEW', 'STATUS_CONNECTING', 'STATUS_CONNECTED', 'STATUS_COMPLETED'];
6307
- const logger$3 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6327
+ const logger$9 = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-client') : console;
6308
6328
  const statsLogger = IssueReporter$1 ? IssueReporter$1.loggerFor('webrtc-stats') : console;
6309
6329
 
6310
6330
  // events
@@ -6318,14 +6338,14 @@ const TRANSPORT_ERROR = 'transportError';
6318
6338
  const MESSAGE = 'message';
6319
6339
  const ACCEPTED = 'accepted';
6320
6340
  const REJECTED = 'rejected';
6321
- const ON_TRACK = 'onTrack';
6322
- const ON_REINVITE = 'reinvite';
6341
+ const ON_TRACK$1 = 'onTrack';
6342
+ const ON_REINVITE$1 = 'reinvite';
6323
6343
  const ON_ERROR = 'onError';
6324
6344
  const ON_SCREEN_SHARING_REINVITE = 'onScreenSharingReinvite';
6325
- const ON_NETWORK_STATS = 'onNetworkStats';
6326
- const ON_DISCONNECTED = 'onDisconnected';
6345
+ const ON_NETWORK_STATS$1 = 'onNetworkStats';
6346
+ const ON_DISCONNECTED$1 = 'onDisconnected';
6327
6347
 
6328
- const events = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6348
+ const events$1 = [REGISTERED, UNREGISTERED, REGISTRATION_FAILED, INVITE];
6329
6349
  const transportEvents = [CONNECTED, DISCONNECTED, TRANSPORT_ERROR, MESSAGE];
6330
6350
  class CanceledCallError extends Error {}
6331
6351
 
@@ -6461,12 +6481,12 @@ class WebRTCClient extends Emitter {
6461
6481
  this.MESSAGE = MESSAGE;
6462
6482
  this.ACCEPTED = ACCEPTED;
6463
6483
  this.REJECTED = REJECTED;
6464
- this.ON_TRACK = ON_TRACK;
6465
- this.ON_REINVITE = ON_REINVITE;
6484
+ this.ON_TRACK = ON_TRACK$1;
6485
+ this.ON_REINVITE = ON_REINVITE$1;
6466
6486
  this.ON_ERROR = ON_ERROR;
6467
6487
  this.ON_SCREEN_SHARING_REINVITE = ON_SCREEN_SHARING_REINVITE;
6468
- this.ON_NETWORK_STATS = ON_NETWORK_STATS;
6469
- this.ON_DISCONNECTED = ON_DISCONNECTED;
6488
+ this.ON_NETWORK_STATS = ON_NETWORK_STATS$1;
6489
+ this.ON_DISCONNECTED = ON_DISCONNECTED$1;
6470
6490
  }
6471
6491
 
6472
6492
  configureMedia(media ) {
@@ -6483,13 +6503,13 @@ class WebRTCClient extends Emitter {
6483
6503
 
6484
6504
  createUserAgent(configOverrides ) {
6485
6505
  const webRTCConfiguration = this._createWebRTCConfiguration(configOverrides);
6486
- logger$3.info('sdk webrtc, creating UA', { webRTCConfiguration });
6506
+ logger$9.info('sdk webrtc, creating UA', { webRTCConfiguration });
6487
6507
 
6488
6508
  webRTCConfiguration.delegate = {
6489
6509
  onConnect: this.onConnect.bind(this),
6490
6510
  onDisconnect: this.onDisconnect.bind(this),
6491
6511
  onInvite: (invitation ) => {
6492
- logger$3.info('sdk webrtc on invite', {
6512
+ logger$9.info('sdk webrtc on invite', {
6493
6513
  method: 'delegate.onInvite',
6494
6514
  id: invitation.id,
6495
6515
  remoteURI: invitation.remoteURI,
@@ -6532,7 +6552,7 @@ class WebRTCClient extends Emitter {
6532
6552
  }
6533
6553
 
6534
6554
  onConnect() {
6535
- logger$3.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6555
+ logger$9.info('sdk webrtc connected', { method: 'delegate.onConnect' });
6536
6556
  this.eventEmitter.emit(CONNECTED);
6537
6557
  if (!this.isRegistered() && this.registerer && this.registerer.waiting) {
6538
6558
  this.registerer.waitingToggle(false);
@@ -6541,7 +6561,7 @@ class WebRTCClient extends Emitter {
6541
6561
  }
6542
6562
 
6543
6563
  async onDisconnect(error ) {
6544
- logger$3.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6564
+ logger$9.info('sdk webrtc disconnected', { method: 'delegate.onConnect', error });
6545
6565
  this.connectionPromise = null;
6546
6566
  // The UA will attempt to reconnect automatically when an error occurred
6547
6567
  this.eventEmitter.emit(DISCONNECTED, error);
@@ -6566,37 +6586,37 @@ class WebRTCClient extends Emitter {
6566
6586
  };
6567
6587
 
6568
6588
  if (this.skipRegister) {
6569
- logger$3.info('sdk webrtc skip register...', logInfo);
6589
+ logger$9.info('sdk webrtc skip register...', logInfo);
6570
6590
  return Promise.resolve();
6571
6591
  }
6572
6592
 
6573
- logger$3.info('sdk webrtc registering...', logInfo);
6593
+ logger$9.info('sdk webrtc registering...', logInfo);
6574
6594
 
6575
6595
  if (!this.userAgent) {
6576
- logger$3.info('sdk webrtc recreating User Agent');
6596
+ logger$9.info('sdk webrtc recreating User Agent');
6577
6597
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6578
6598
  }
6579
6599
  if (!this.userAgent || this.isRegistered()) {
6580
- logger$3.info('sdk webrtc registering aborted, already registered or no UA can be created');
6600
+ logger$9.info('sdk webrtc registering aborted, already registered or no UA can be created');
6581
6601
  return Promise.resolve();
6582
6602
  }
6583
6603
 
6584
6604
  if (this.connectionPromise || (this.registerer && this.registerer.waiting)) {
6585
- logger$3.info('sdk webrtc registering aborted due to a registration in progress.');
6605
+ logger$9.info('sdk webrtc registering aborted due to a registration in progress.');
6586
6606
  return Promise.resolve();
6587
6607
  }
6588
6608
 
6589
6609
  const registerOptions = this._isWeb() ? {} : { extraContactHeaderParams: ['mobility=mobile'] };
6590
6610
 
6591
6611
  const onRegisterFailed = () => {
6592
- logger$3.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6612
+ logger$9.info('sdk webrtc registering failed', { tries, registerer: !!this.registerer });
6593
6613
  this.connectionPromise = null;
6594
6614
  if (this.registerer && this.registerer.waiting) {
6595
6615
  this.registerer.waitingToggle(false);
6596
6616
  }
6597
6617
 
6598
6618
  if (tries <= MAX_REGISTER_TRIES) {
6599
- logger$3.info('sdk webrtc registering, retrying...', { tries });
6619
+ logger$9.info('sdk webrtc registering, retrying...', { tries });
6600
6620
  setTimeout(() => this.register(tries + 1), 300);
6601
6621
  }
6602
6622
  };
@@ -6605,18 +6625,18 @@ class WebRTCClient extends Emitter {
6605
6625
  // Avoid race condition with the close method called just before register and setting userAgent to null
6606
6626
  // during the resolution of the primise.
6607
6627
  if (!this.userAgent) {
6608
- logger$3.info('sdk webrtc recreating User Agent after connection');
6628
+ logger$9.info('sdk webrtc recreating User Agent after connection');
6609
6629
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
6610
6630
  }
6611
6631
 
6612
- logger$3.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6632
+ logger$9.info('sdk webrtc registering, transport connected', { registerOptions, ua: !!this.userAgent });
6613
6633
  this.registerer = new Registerer(this.userAgent, registerOptions);
6614
6634
  this.connectionPromise = null;
6615
6635
  this._monkeyPatchRegisterer(this.registerer);
6616
6636
 
6617
6637
  // Bind registerer events
6618
6638
  this.registerer.stateChange.addListener(newState => {
6619
- logger$3.info('sdk webrtc registering, state changed', { newState });
6639
+ logger$9.info('sdk webrtc registering, state changed', { newState });
6620
6640
 
6621
6641
  if (newState === RegistererState.Registered && this.registerer
6622
6642
  && this.registerer.state === RegistererState.Registered) {
@@ -6629,7 +6649,7 @@ class WebRTCClient extends Emitter {
6629
6649
  const options = {
6630
6650
  requestDelegate: {
6631
6651
  onReject: response => {
6632
- logger$3.error('sdk webrtc registering, rejected', { response });
6652
+ logger$9.error('sdk webrtc registering, rejected', { response });
6633
6653
 
6634
6654
  onRegisterFailed();
6635
6655
  },
@@ -6637,13 +6657,13 @@ class WebRTCClient extends Emitter {
6637
6657
  };
6638
6658
 
6639
6659
  return this.registerer.register(options).catch((e) => {
6640
- logger$3.error('sdk webrtc registering, error', e);
6660
+ logger$9.error('sdk webrtc registering, error', e);
6641
6661
 
6642
6662
  this.eventEmitter.emit(REGISTRATION_FAILED);
6643
6663
  return e;
6644
6664
  });
6645
6665
  }).catch(error => {
6646
- logger$3.error('sdk webrtc registering, transport error', error);
6666
+ logger$9.error('sdk webrtc registering, transport error', error);
6647
6667
  onRegisterFailed();
6648
6668
  });
6649
6669
  }
@@ -6672,21 +6692,21 @@ class WebRTCClient extends Emitter {
6672
6692
  }
6673
6693
 
6674
6694
  unregister() {
6675
- logger$3.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6695
+ logger$9.info('sdk webrtc unregistering..', { userAgent: !!this.userAgent, registerer: !!this.registerer });
6676
6696
  if (!this.registerer) {
6677
6697
  return Promise.resolve();
6678
6698
  }
6679
6699
 
6680
6700
  try {
6681
6701
  return this.registerer.unregister().then(() => {
6682
- logger$3.info('sdk webrtc unregistered');
6702
+ logger$9.info('sdk webrtc unregistered');
6683
6703
  this._cleanupRegister();
6684
6704
  }).catch(e => {
6685
- logger$3.error('sdk webrtc unregistering, promise error', e);
6705
+ logger$9.error('sdk webrtc unregistering, promise error', e);
6686
6706
  this._cleanupRegister();
6687
6707
  });
6688
6708
  } catch (e) {
6689
- logger$3.error('sdk webrtc unregistering, error', e);
6709
+ logger$9.error('sdk webrtc unregistering, error', e);
6690
6710
  // Avoid issue with `undefined is not an object (evaluating 'new.target.prototype')` when triggering a new
6691
6711
  // error when the registerer is in a bad state
6692
6712
  this._cleanupRegister();
@@ -6694,7 +6714,7 @@ class WebRTCClient extends Emitter {
6694
6714
  }
6695
6715
 
6696
6716
  stop() {
6697
- logger$3.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6717
+ logger$9.info('sdk webrtc stop', { userAgent: !!this.userAgent });
6698
6718
  if (!this.userAgent) {
6699
6719
  return Promise.resolve();
6700
6720
  }
@@ -6702,12 +6722,12 @@ class WebRTCClient extends Emitter {
6702
6722
  return this.userAgent.stop().then(() => {
6703
6723
  return this._cleanupRegister();
6704
6724
  }).catch(e => {
6705
- logger$3.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6725
+ logger$9.warn('sdk webrtc stop, error', { message: e.message, stack: e.stack });
6706
6726
  });
6707
6727
  }
6708
6728
 
6709
6729
  call(number , enableVideo , audioOnly = false, conference = false) {
6710
- logger$3.info('sdk webrtc creating call', { number, enableVideo, audioOnly });
6730
+ logger$9.info('sdk webrtc creating call', { number, enableVideo, audioOnly, conference });
6711
6731
  const inviterOptions = {
6712
6732
  sessionDescriptionHandlerOptionsReInvite: {
6713
6733
  conference,
@@ -6738,7 +6758,7 @@ class WebRTCClient extends Emitter {
6738
6758
  this._onAccepted(session, response.session, true);
6739
6759
  },
6740
6760
  onReject: (response ) => {
6741
- logger$3.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6761
+ logger$9.info('on call rejected', { id: session.id, fromTag: session.fromTag });
6742
6762
  this._stopSendingStats(session);
6743
6763
  this.stopNetworkMonitoring(session);
6744
6764
 
@@ -6761,11 +6781,11 @@ class WebRTCClient extends Emitter {
6761
6781
  }
6762
6782
 
6763
6783
  answer(session , enableVideo ) {
6764
- logger$3.info('sdk webrtc answer call', { id: session.id, enableVideo });
6784
+ logger$9.info('sdk webrtc answer call', { id: session.id, enableVideo });
6765
6785
 
6766
6786
  if (!session || !session.accept) {
6767
6787
  const error = 'No session to answer, or not an invitation';
6768
- logger$3.warn(error);
6788
+ logger$9.warn(error);
6769
6789
  return Promise.reject(new Error(error));
6770
6790
  }
6771
6791
  const options = {
@@ -6775,15 +6795,15 @@ class WebRTCClient extends Emitter {
6775
6795
  return session.accept(options).then(() => {
6776
6796
  if (session.isCanceled) {
6777
6797
  const message = 'accepted a canceled session (or was canceled during the accept phase).';
6778
- logger$3.error(message, { id: session.id });
6798
+ logger$9.error(message, { id: session.id });
6779
6799
  this.onCallEnded(session);
6780
6800
 
6781
6801
  throw new CanceledCallError(message);
6782
6802
  }
6783
- logger$3.info('sdk webrtc answer, accepted.');
6803
+ logger$9.info('sdk webrtc answer, accepted.');
6784
6804
  this._onAccepted(session);
6785
6805
  }).catch(e => {
6786
- logger$3.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6806
+ logger$9.error(`answer call error for ${session ? session.id : 'n/a'}`, e);
6787
6807
 
6788
6808
  throw e;
6789
6809
  });
@@ -6791,7 +6811,7 @@ class WebRTCClient extends Emitter {
6791
6811
 
6792
6812
  hangup(session ) {
6793
6813
  const { state, id } = session;
6794
- logger$3.info('sdk webrtc hangup call', { id, state });
6814
+ logger$9.info('sdk webrtc hangup call', { id, state });
6795
6815
 
6796
6816
  try {
6797
6817
  this._stopSendingStats(session);
@@ -6820,7 +6840,7 @@ class WebRTCClient extends Emitter {
6820
6840
 
6821
6841
  return bye();
6822
6842
  } catch (error) {
6823
- logger$3.warn('sdk webrtc hangup, error', error);
6843
+ logger$9.warn('sdk webrtc hangup, error', error);
6824
6844
  }
6825
6845
 
6826
6846
  return null;
@@ -6838,7 +6858,7 @@ class WebRTCClient extends Emitter {
6838
6858
  // Fetch and emit an event at `interval` with session network stats
6839
6859
  startNetworkMonitoring(session , interval = 1000) {
6840
6860
  const sessionId = this.getSipSessionId(session);
6841
- logger$3.info('starting network inspection', { id: sessionId });
6861
+ logger$9.info('starting network inspection', { id: sessionId });
6842
6862
 
6843
6863
  this.sessionNetworkStats[sessionId] = [];
6844
6864
 
@@ -6848,7 +6868,7 @@ class WebRTCClient extends Emitter {
6848
6868
  stopNetworkMonitoring(session ) {
6849
6869
  const sessionId = this.getSipSessionId(session);
6850
6870
  const exists = sessionId in this.networkMonitoringInterval;
6851
- logger$3.info('stopping network inspection', { id: sessionId, exists });
6871
+ logger$9.info('stopping network inspection', { id: sessionId, exists });
6852
6872
 
6853
6873
  if (exists) {
6854
6874
  clearInterval(this.networkMonitoringInterval[sessionId]);
@@ -6858,17 +6878,17 @@ class WebRTCClient extends Emitter {
6858
6878
  }
6859
6879
 
6860
6880
  reject(session ) {
6861
- logger$3.info('sdk webrtc reject call', { id: session.id });
6881
+ logger$9.info('sdk webrtc reject call', { id: session.id });
6862
6882
 
6863
6883
  try {
6864
6884
  return session.reject ? session.reject() : session.cancel();
6865
6885
  } catch (e) {
6866
- logger$3.warn('Error when rejecting call', e.message, e.stack);
6886
+ logger$9.warn('Error when rejecting call', e.message, e.stack);
6867
6887
  }
6868
6888
  }
6869
6889
 
6870
6890
  async close() {
6871
- logger$3.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6891
+ logger$9.info('sdk webrtc closing client', { userAgent: !!this.userAgent });
6872
6892
  this._cleanupMedia();
6873
6893
  this.connectionPromise = null;
6874
6894
 
@@ -6899,7 +6919,7 @@ class WebRTCClient extends Emitter {
6899
6919
  // eg: "INVITE not rejectable in state Completed"
6900
6920
  }
6901
6921
  this.userAgent = null;
6902
- logger$3.info('sdk webrtc client closed');
6922
+ logger$9.info('sdk webrtc client closed');
6903
6923
  }
6904
6924
 
6905
6925
  getNumber(session ) {
@@ -6912,13 +6932,13 @@ class WebRTCClient extends Emitter {
6912
6932
  }
6913
6933
 
6914
6934
  mute(session ) {
6915
- logger$3.info('sdk webrtc mute', { id: session.id });
6935
+ logger$9.info('sdk webrtc mute', { id: session.id });
6916
6936
 
6917
6937
  this._toggleAudio(session, true);
6918
6938
  }
6919
6939
 
6920
6940
  unmute(session ) {
6921
- logger$3.info('sdk webrtc unmute', { id: session.id });
6941
+ logger$9.info('sdk webrtc unmute', { id: session.id });
6922
6942
 
6923
6943
  this._toggleAudio(session, false);
6924
6944
  }
@@ -6958,13 +6978,13 @@ class WebRTCClient extends Emitter {
6958
6978
  }
6959
6979
 
6960
6980
  toggleCameraOn(session ) {
6961
- logger$3.info('sdk webrtc toggle camera on', { id: session.id });
6981
+ logger$9.info('sdk webrtc toggle camera on', { id: session.id });
6962
6982
 
6963
6983
  this._toggleVideo(session, false);
6964
6984
  }
6965
6985
 
6966
6986
  toggleCameraOff(session ) {
6967
- logger$3.info('sdk webrtc toggle camera off', { id: session.id });
6987
+ logger$9.info('sdk webrtc toggle camera off', { id: session.id });
6968
6988
 
6969
6989
  this._toggleVideo(session, true);
6970
6990
  }
@@ -6973,7 +6993,7 @@ class WebRTCClient extends Emitter {
6973
6993
  const sessionId = this.getSipSessionId(session);
6974
6994
  const hasVideo = hadVideo || this.hasLocalVideo(sessionId);
6975
6995
 
6976
- logger$3.info('sdk webrtc hold', {
6996
+ logger$9.info('sdk webrtc hold', {
6977
6997
  sessionId,
6978
6998
  keys: Object.keys(this.heldSessions),
6979
6999
  pendingReinvite: !!session.pendingReinvite,
@@ -7022,7 +7042,7 @@ class WebRTCClient extends Emitter {
7022
7042
  const sessionId = this.getSipSessionId(session);
7023
7043
  const hasVideo = sessionId in this.heldSessions && this.heldSessions[sessionId].hasVideo;
7024
7044
 
7025
- logger$3.info('sdk webrtc unhold', {
7045
+ logger$9.info('sdk webrtc unhold', {
7026
7046
  sessionId,
7027
7047
  keys: Object.keys(this.heldSessions),
7028
7048
  pendingReinvite: !!session.pendingReinvite,
@@ -7170,7 +7190,7 @@ class WebRTCClient extends Emitter {
7170
7190
  if (!session.sessionDescriptionHandler) {
7171
7191
  return;
7172
7192
  }
7173
- logger$3.info('Sending DTMF', {
7193
+ logger$9.info('Sending DTMF', {
7174
7194
  id: this.getSipSessionId(session),
7175
7195
  tone,
7176
7196
  });
@@ -7186,7 +7206,7 @@ class WebRTCClient extends Emitter {
7186
7206
  transfer(session , target ) {
7187
7207
  this.hold(session);
7188
7208
 
7189
- logger$3.info('Transfering a session', {
7209
+ logger$9.info('Transfering a session', {
7190
7210
  id: this.getSipSessionId(session),
7191
7211
  target,
7192
7212
  });
@@ -7208,17 +7228,17 @@ class WebRTCClient extends Emitter {
7208
7228
  atxfer(session ) {
7209
7229
  this.hold(session);
7210
7230
 
7211
- logger$3.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7231
+ logger$9.info('webrtc transfer started', { id: this.getSipSessionId(session) });
7212
7232
 
7213
7233
  const result = {
7214
7234
  newSession: null,
7215
7235
  init: async (target ) => {
7216
- logger$3.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7236
+ logger$9.info('webrtc transfer initialized', { id: this.getSipSessionId(session), target });
7217
7237
 
7218
7238
  result.newSession = await this.call(target);
7219
7239
  },
7220
7240
  complete: () => {
7221
- logger$3.info('webrtc transfer completed', {
7241
+ logger$9.info('webrtc transfer completed', {
7222
7242
  id: this.getSipSessionId(session),
7223
7243
  referId: this.getSipSessionId(result.newSession),
7224
7244
  });
@@ -7239,7 +7259,7 @@ class WebRTCClient extends Emitter {
7239
7259
  return;
7240
7260
  }
7241
7261
 
7242
- logger$3.info('send WebRTC message', { sipId: sipSession.id, contentType });
7262
+ logger$9.info('send WebRTC message', { sipId: sipSession.id, contentType });
7243
7263
 
7244
7264
  try {
7245
7265
  sipSession.message({
@@ -7281,7 +7301,7 @@ class WebRTCClient extends Emitter {
7281
7301
  }
7282
7302
 
7283
7303
  changeAudioOutputVolume(volume ) {
7284
- logger$3.info('Changing audio output volume', { volume });
7304
+ logger$9.info('Changing audio output volume', { volume });
7285
7305
 
7286
7306
  Object.values(this.audioElements).forEach(audioElement => {
7287
7307
  if (audioElement instanceof HTMLAudioElement) {
@@ -7293,7 +7313,7 @@ class WebRTCClient extends Emitter {
7293
7313
  }
7294
7314
 
7295
7315
  changeAudioOutputDevice(id ) {
7296
- logger$3.info('Changing audio output device', { id });
7316
+ logger$9.info('Changing audio output device', { id });
7297
7317
 
7298
7318
  Object.values(this.audioElements).forEach(audioElement => {
7299
7319
  // `setSinkId` method is not included in any flow type definitions for HTMLAudioElements but is a valid method
@@ -7310,7 +7330,7 @@ class WebRTCClient extends Emitter {
7310
7330
 
7311
7331
  changeAudioInputDevice(id , session ) {
7312
7332
  const currentId = this.getAudioDeviceId();
7313
- logger$3.info('setting audio input device', { id, currentId, session: !!session });
7333
+ logger$9.info('setting audio input device', { id, currentId, session: !!session });
7314
7334
 
7315
7335
  if (id === currentId) {
7316
7336
  return null;
@@ -7356,7 +7376,7 @@ class WebRTCClient extends Emitter {
7356
7376
 
7357
7377
  setVideoInputDevice(id ) {
7358
7378
  const currentId = this.getVideoDeviceId();
7359
- logger$3.info('setting video input device', { id, currentId });
7379
+ logger$9.info('setting video input device', { id, currentId });
7360
7380
 
7361
7381
  if (id === currentId) {
7362
7382
  return null;
@@ -7381,7 +7401,7 @@ class WebRTCClient extends Emitter {
7381
7401
  const sessionId = this.getSipSessionId(session);
7382
7402
  const localStream = this.getLocalStream(sessionId);
7383
7403
 
7384
- logger$3.info('changing video input device', { id, sessionId });
7404
+ logger$9.info('changing video input device', { id, sessionId });
7385
7405
 
7386
7406
  // Release old video stream
7387
7407
  if (localStream) {
@@ -7449,7 +7469,7 @@ class WebRTCClient extends Emitter {
7449
7469
  const shouldDoScreenSharing = newConstraints && newConstraints.screen;
7450
7470
  const desktop = newConstraints && newConstraints.desktop;
7451
7471
 
7452
- logger$3.info('Sending reinvite', {
7472
+ logger$9.info('Sending reinvite', {
7453
7473
  id: this.getSipSessionId(sipSession),
7454
7474
  newConstraints,
7455
7475
  conference,
@@ -7487,7 +7507,7 @@ class WebRTCClient extends Emitter {
7487
7507
  sipSession.incomingInviteRequest.message.body = response.message.body;
7488
7508
  }
7489
7509
 
7490
- logger$3.info('on re-INVITE accepted', {
7510
+ logger$9.info('on re-INVITE accepted', {
7491
7511
  id: this.getSipSessionId(sipSession),
7492
7512
  wasMuted,
7493
7513
  shouldDoScreenSharing,
@@ -7505,7 +7525,7 @@ class WebRTCClient extends Emitter {
7505
7525
  this.eventEmitter.emit(ON_SCREEN_SHARING_REINVITE, sipSession, response, desktop);
7506
7526
  }
7507
7527
 
7508
- return this.eventEmitter.emit(ON_REINVITE, sipSession, response);
7528
+ return this.eventEmitter.emit(ON_REINVITE$1, sipSession, response);
7509
7529
  },
7510
7530
  },
7511
7531
  sessionDescriptionHandlerModifiers: [replaceLocalIpModifier],
@@ -7662,7 +7682,7 @@ class WebRTCClient extends Emitter {
7662
7682
  }
7663
7683
 
7664
7684
  startHeartbeat() {
7665
- logger$3.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7685
+ logger$9.info('sdk webrtc start heartbeat', { userAgent: !!this.userAgent });
7666
7686
  if (!this.userAgent) {
7667
7687
  this.heartbeat.stop();
7668
7688
  return;
@@ -7675,7 +7695,7 @@ class WebRTCClient extends Emitter {
7675
7695
  }
7676
7696
 
7677
7697
  stopHeartbeat() {
7678
- logger$3.info('sdk webrtc stop heartbeat');
7698
+ logger$9.info('sdk webrtc stop heartbeat');
7679
7699
  this.heartbeat.stop();
7680
7700
  }
7681
7701
 
@@ -7696,7 +7716,7 @@ class WebRTCClient extends Emitter {
7696
7716
  }
7697
7717
 
7698
7718
  attemptReconnection() {
7699
- logger$3.info('attempt reconnection', { userAgent: !!this.userAgent });
7719
+ logger$9.info('attempt reconnection', { userAgent: !!this.userAgent });
7700
7720
  if (!this.userAgent) {
7701
7721
  return;
7702
7722
  }
@@ -7721,7 +7741,7 @@ class WebRTCClient extends Emitter {
7721
7741
  return;
7722
7742
  }
7723
7743
 
7724
- logger$3.info('setting local media stream', {
7744
+ logger$9.info('setting local media stream', {
7725
7745
  sipSessionId,
7726
7746
  tracks: newStream ? newStream.getTracks() : null,
7727
7747
  });
@@ -7738,7 +7758,7 @@ class WebRTCClient extends Emitter {
7738
7758
 
7739
7759
  const oldStream = this.getLocalStream(sipSessionId);
7740
7760
 
7741
- logger$3.info('updating local stream', {
7761
+ logger$9.info('updating local stream', {
7742
7762
  sipSessionId,
7743
7763
  oldStream: !!oldStream,
7744
7764
  tracks: newStream.getTracks(),
@@ -7758,7 +7778,7 @@ class WebRTCClient extends Emitter {
7758
7778
  const remoteStream = this.getRemoteStream(sessionId);
7759
7779
  const pc = this.getPeerConnection(sessionId);
7760
7780
 
7761
- logger$3.info('Updating remote stream', {
7781
+ logger$9.info('Updating remote stream', {
7762
7782
  sessionId,
7763
7783
  tracks: remoteStream ? remoteStream.getTracks() : null,
7764
7784
  receiverTracks: pc && pc.getReceivers ? pc.getReceivers().map(receiver => receiver.track) : null,
@@ -7783,14 +7803,16 @@ class WebRTCClient extends Emitter {
7783
7803
  const screenSharing = constraints && 'screen' in constraints ? constraints.screen : false;
7784
7804
  const isDesktop = constraints && 'desktop' in constraints ? constraints.desktop : false;
7785
7805
  const withAudio = constraints && 'audio' in constraints ? constraints.audio : true;
7806
+ const mandatoryVideo = constraints && typeof constraints.video === 'object' ? constraints.video.mandatory : {};
7786
7807
 
7787
- logger$3.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7808
+ logger$9.info('Retrieving media a configuration', { enableVideo, screenSharing, isDesktop, withAudio, constraints });
7788
7809
 
7789
7810
  return {
7790
7811
  constraints: {
7791
7812
  // Exact constraint are not supported with `getDisplayMedia` and we must have a video=false in desktop screenshare
7792
7813
  audio: screenSharing ? !isDesktop : (withAudio ? this._getAudioConstraints() : false),
7793
- video: screenSharing ? (isDesktop ? ({ mandatory: { chromeMediaSource: 'desktop' } }) : { cursor: 'always' })
7814
+ video: screenSharing ? (isDesktop
7815
+ ? ({ mandatory: { chromeMediaSource: 'desktop', ...(mandatoryVideo || {}) } }) : { cursor: 'always' })
7794
7816
  : this._getVideoConstraints(enableVideo),
7795
7817
  screen: screenSharing,
7796
7818
  desktop: isDesktop,
@@ -7833,7 +7855,7 @@ class WebRTCClient extends Emitter {
7833
7855
  }
7834
7856
 
7835
7857
  _onTransportError() {
7836
- logger$3.error('on transport error');
7858
+ logger$9.error('on transport error');
7837
7859
  this.eventEmitter.emit(TRANSPORT_ERROR);
7838
7860
  this.attemptReconnection();
7839
7861
  }
@@ -7842,7 +7864,7 @@ class WebRTCClient extends Emitter {
7842
7864
  const body = message && typeof message === 'object' ? message.data : message;
7843
7865
  if (body && body.indexOf('200 OK') !== -1) {
7844
7866
  if (this.hasHeartbeat()) {
7845
- logger$3.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7867
+ logger$9.info('on heartbeat received from Asterisk', { hasHeartbeat: this.hasHeartbeat() });
7846
7868
 
7847
7869
  this.heartbeat.onHeartbeat();
7848
7870
  if (this.heartbeatCb) {
@@ -7853,7 +7875,7 @@ class WebRTCClient extends Emitter {
7853
7875
  }
7854
7876
 
7855
7877
  async _onHeartbeatTimeout() {
7856
- logger$3.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7878
+ logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
7857
7879
 
7858
7880
  if (this.heartbeatTimeoutCb) {
7859
7881
  this.heartbeatTimeoutCb();
@@ -7865,7 +7887,7 @@ class WebRTCClient extends Emitter {
7865
7887
  try {
7866
7888
  await this.userAgent.transport.disconnect();
7867
7889
  } catch (e) {
7868
- logger$3.error('Transport disconnection after heartbeat timeout, error', e);
7890
+ logger$9.error('Transport disconnection after heartbeat timeout, error', e);
7869
7891
  }
7870
7892
  }
7871
7893
 
@@ -7898,31 +7920,31 @@ class WebRTCClient extends Emitter {
7898
7920
  }
7899
7921
 
7900
7922
  _connectIfNeeded() {
7901
- logger$3.info('connect if needed, checking', { connected: this.isConnected() });
7923
+ logger$9.info('connect if needed, checking', { connected: this.isConnected() });
7902
7924
  if (!this.userAgent) {
7903
- logger$3.info('need to recreate User Agent');
7925
+ logger$9.info('need to recreate User Agent');
7904
7926
  this.userAgent = this.createUserAgent(this.uaConfigOverrides);
7905
7927
  }
7906
7928
 
7907
7929
  if (this.isConnected()) {
7908
- logger$3.info('webrtc sdk, already connected');
7930
+ logger$9.info('webrtc sdk, already connected');
7909
7931
  return Promise.resolve();
7910
7932
  }
7911
7933
 
7912
7934
  if (this.isConnecting()) {
7913
- logger$3.info('webrtc sdk, already connecting...');
7935
+ logger$9.info('webrtc sdk, already connecting...');
7914
7936
 
7915
7937
  this.connectionPromise = this.userAgent.transport.connectPromise;
7916
7938
  return this.connectionPromise;
7917
7939
  }
7918
7940
 
7919
7941
  if (this.connectionPromise) {
7920
- logger$3.info('webrtc sdk, connection promise connecting...');
7942
+ logger$9.info('webrtc sdk, connection promise connecting...');
7921
7943
  // $FlowFixMe
7922
7944
  return this.connectionPromise;
7923
7945
  }
7924
7946
 
7925
- logger$3.info('WebRTC UA needs to connect');
7947
+ logger$9.info('WebRTC UA needs to connect');
7926
7948
 
7927
7949
  // Force UA to reconnect
7928
7950
  if (this.userAgent && this.userAgent.state !== UserAgentState.Stopped) {
@@ -8047,7 +8069,7 @@ class WebRTCClient extends Emitter {
8047
8069
 
8048
8070
  sdh.peerConnectionDelegate = {
8049
8071
  onicecandidateerror: (error ) => {
8050
- logger$3.error('on icecandidate error', {
8072
+ logger$9.error('on icecandidate error', {
8051
8073
  address: error.address,
8052
8074
  port: error.port,
8053
8075
  errorCode: error.errorCode,
@@ -8076,7 +8098,7 @@ class WebRTCClient extends Emitter {
8076
8098
  updatedNumber = session.assertedIdentity.uri.normal.user;
8077
8099
  updatedCalleeName = session.assertedIdentity.displayName || updatedNumber;
8078
8100
  }
8079
- logger$3.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8101
+ logger$9.info('re-invite received', { updatedCalleeName, updatedNumber, hadRemoteVideo });
8080
8102
 
8081
8103
  // Useful to know if it's a video upgrade or an unhold from a remote peer with a video stream
8082
8104
 
@@ -8092,12 +8114,12 @@ class WebRTCClient extends Emitter {
8092
8114
 
8093
8115
  this._setupMedias(session);
8094
8116
 
8095
- return this.eventEmitter.emit(ON_REINVITE, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8117
+ return this.eventEmitter.emit(ON_REINVITE$1, session, request, updatedCalleeName, updatedNumber, hadRemoteVideo);
8096
8118
  };
8097
8119
  }
8098
8120
 
8099
8121
  _onAccepted(session , sessionDialog , withEvent = true) {
8100
- logger$3.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8122
+ logger$9.info('on call accepted', { id: session.id, remoteTag: session.remoteTag });
8101
8123
 
8102
8124
  this.storeSipSession(session);
8103
8125
 
@@ -8109,14 +8131,14 @@ class WebRTCClient extends Emitter {
8109
8131
  const onTrack = (event ) => {
8110
8132
  const isAudioOnly = this._isAudioOnly(session);
8111
8133
  const { kind, label, readyState, id, muted } = event.track;
8112
- logger$3.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8134
+ logger$9.info('on track event', { isAudioOnly, kind, label, readyState, id, muted });
8113
8135
 
8114
8136
  // Stop video track in audio only mode
8115
8137
  if (isAudioOnly && kind === 'video') {
8116
8138
  event.track.stop();
8117
8139
  }
8118
8140
 
8119
- this.eventEmitter.emit(ON_TRACK, session, event);
8141
+ this.eventEmitter.emit(ON_TRACK$1, session, event);
8120
8142
  };
8121
8143
 
8122
8144
  if (session.sessionDescriptionHandler.peerConnection) {
@@ -8125,12 +8147,14 @@ class WebRTCClient extends Emitter {
8125
8147
 
8126
8148
  session.sessionDescriptionHandler.remoteMediaStream.onaddtrack = onTrack;
8127
8149
 
8128
- pc.oniceconnectionstatechange = () => {
8129
- logger$3.info('on ice connection state changed', { state: pc.iceConnectionState });
8130
- if (pc.iceConnectionState === 'disconnected') {
8131
- this.eventEmitter.emit(ON_DISCONNECTED);
8132
- }
8133
- };
8150
+ if (pc) {
8151
+ pc.oniceconnectionstatechange = () => {
8152
+ logger$9.info('on ice connection state changed', { state: pc.iceConnectionState });
8153
+ if (pc.iceConnectionState === 'disconnected') {
8154
+ this.eventEmitter.emit(ON_DISCONNECTED$1);
8155
+ }
8156
+ };
8157
+ }
8134
8158
 
8135
8159
  if (withEvent) {
8136
8160
  this.eventEmitter.emit(ACCEPTED, session, sessionDialog);
@@ -8299,10 +8323,10 @@ class WebRTCClient extends Emitter {
8299
8323
 
8300
8324
  _stopSendingStats(session ) {
8301
8325
  const sessionId = this.getSipSessionId(session);
8302
- logger$3.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8326
+ logger$9.trace('Check for stopping stats', { sessionId, ids: Object.keys(this.statsIntervals) });
8303
8327
 
8304
8328
  if (sessionId in this.statsIntervals) {
8305
- logger$3.trace('Stop sending stats for call', { sessionId });
8329
+ logger$9.trace('Stop sending stats for call', { sessionId });
8306
8330
  this.statsIntervals[sessionId]();
8307
8331
  delete this.statsIntervals[sessionId];
8308
8332
  }
@@ -8318,7 +8342,7 @@ class WebRTCClient extends Emitter {
8318
8342
  try {
8319
8343
  await this.userAgent.transport.disconnect();
8320
8344
  } catch (e) {
8321
- logger$3.error('WebRTC transport disconnect, error', e);
8345
+ logger$9.error('WebRTC transport disconnect, error', e);
8322
8346
  }
8323
8347
  }
8324
8348
  }
@@ -8340,13 +8364,17 @@ class WebRTCClient extends Emitter {
8340
8364
  const nbStats = this.sessionNetworkStats[sessionId].length;
8341
8365
  const lastNetworkStats = this.sessionNetworkStats[sessionId][nbStats - 1];
8342
8366
  const lastAudioSent = lastNetworkStats ? lastNetworkStats.audioBytesSent : 0;
8367
+ const lastAudioContentSent = lastNetworkStats ? lastNetworkStats.audioContentSent : 0;
8343
8368
  const lastVideoSent = lastNetworkStats ? lastNetworkStats.videoBytesSent : 0;
8344
8369
  const lastAudioReceived = lastNetworkStats ? lastNetworkStats.audioBytesReceived : 0;
8370
+ const lastAudioContentReceived = lastNetworkStats ? lastNetworkStats.audioContentReceived : 0;
8345
8371
  const lastVideoReceived = lastNetworkStats ? lastNetworkStats.videoBytesReceived : 0;
8346
8372
  const lastTransportSent = lastNetworkStats ? lastNetworkStats.transportSent : 0;
8347
8373
  const lastTransportReceived = lastNetworkStats ? lastNetworkStats.transportReceived : 0;
8348
- let audioBytesSent = 0;
8349
- let audioBytesReceived = 0;
8374
+ let audioBytesSent = 0; // content + header
8375
+ let audioBytesReceived = 0; // content + header
8376
+ let audioContentSent = 0; // useful to detect blank call
8377
+ let audioContentReceived = 0;
8350
8378
  let videoBytesSent = 0;
8351
8379
  let videoBytesReceived = 0;
8352
8380
  let transportSent = 0;
@@ -8356,6 +8384,7 @@ class WebRTCClient extends Emitter {
8356
8384
  stats.forEach(report => {
8357
8385
  if (report.type === 'outbound-rtp' && report.kind === 'audio') {
8358
8386
  audioBytesSent += Number(report.bytesSent) + Number(report.headerBytesSent);
8387
+ audioContentSent += Number(report.bytesSent);
8359
8388
  }
8360
8389
  if (report.type === 'remote-outbound-rtp' && report.kind === 'audio') {
8361
8390
  audioBytesSent += Number(report.bytesSent);
@@ -8367,6 +8396,7 @@ class WebRTCClient extends Emitter {
8367
8396
  packetsLost += Number(report.packetsLost);
8368
8397
  networkStats.packetsReceived = Number(report.packetsReceived);
8369
8398
  audioBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
8399
+ audioContentReceived += Number(report.bytesReceived);
8370
8400
  }
8371
8401
  if (report.type === 'inbound-rtp' && report.kind === 'video') {
8372
8402
  videoBytesReceived += Number(report.bytesReceived) + Number(report.headerBytesReceived);
@@ -8395,10 +8425,17 @@ class WebRTCClient extends Emitter {
8395
8425
  });
8396
8426
 
8397
8427
  networkStats.packetsLost = packetsLost;
8428
+
8398
8429
  networkStats.totalAudioBytesSent = audioBytesSent;
8399
8430
  networkStats.audioBytesSent = audioBytesSent - lastAudioSent;
8400
8431
  networkStats.totalAudioBytesReceived = audioBytesReceived - lastAudioReceived;
8401
8432
  networkStats.audioBytesReceived = audioBytesReceived;
8433
+
8434
+ networkStats.totalAudioContentSent = audioContentSent;
8435
+ networkStats.audioContentSent = audioContentSent - lastAudioContentSent;
8436
+ networkStats.totalAudioBytesReceived = audioContentReceived - lastAudioContentReceived;
8437
+ networkStats.audioContentReceived = audioContentReceived;
8438
+
8402
8439
  networkStats.totalVideoBytesSent = videoBytesSent;
8403
8440
  networkStats.videoBytesSent = videoBytesSent - lastVideoSent;
8404
8441
  networkStats.totalVideoBytesReceived = videoBytesReceived;
@@ -8412,7 +8449,7 @@ class WebRTCClient extends Emitter {
8412
8449
  + networkStats.videoBytesSent + networkStats.videoBytesReceived + networkStats.transportReceived
8413
8450
  + networkStats.transportSent;
8414
8451
 
8415
- this.eventEmitter.emit(ON_NETWORK_STATS, session, networkStats, this.sessionNetworkStats[sessionId]);
8452
+ this.eventEmitter.emit(ON_NETWORK_STATS$1, session, networkStats, this.sessionNetworkStats[sessionId]);
8416
8453
  this.sessionNetworkStats[sessionId].push(networkStats);
8417
8454
  }
8418
8455
 
@@ -8437,11 +8474,12 @@ const ON_CAMERA_DISABLED = 'onCameraDisabled';
8437
8474
  const ON_CAMERA_RESUMED = 'onCameraResumed';
8438
8475
  const ON_CALL_CANCELED = 'onCallCanceled';
8439
8476
  const ON_CALL_FAILED = 'onCallFailed';
8477
+ const ON_CALL_REJECTED = 'onCallRejected';
8440
8478
  const ON_CALL_ENDED = 'onCallEnded';
8441
8479
  const ON_CALL_ENDING = 'onCallEnding';
8442
8480
  const ON_MESSAGE = 'onMessage';
8443
- const ON_REINVITE$1 = 'reinvite';
8444
- const ON_TRACK$1 = 'onTrack';
8481
+ const ON_REINVITE = 'reinvite';
8482
+ const ON_TRACK = 'onTrack';
8445
8483
  const ON_AUDIO_STREAM = 'onAudioStream';
8446
8484
  const ON_VIDEO_STREAM = 'onVideoStream';
8447
8485
  const ON_REMOVE_STREAM = 'onRemoveStream';
@@ -8456,15 +8494,15 @@ const ON_PLAY_PROGRESS_SOUND = 'playProgressSound';
8456
8494
  const ON_VIDEO_INPUT_CHANGE = 'videoInputChange';
8457
8495
  const ON_CALL_ERROR = 'onCallError';
8458
8496
  const ON_MESSAGE_TRACK_UPDATED = 'onTrackUpdated';
8459
- const ON_NETWORK_STATS$1 = 'onNetworkStats';
8497
+ const ON_NETWORK_STATS = 'onNetworkStats';
8460
8498
  const ON_CHAT = 'phone/ON_CHAT';
8461
8499
  const ON_SIGNAL = 'phone/ON_SIGNAL';
8462
- const ON_DISCONNECTED$1 = 'onDisconnected';
8500
+ const ON_DISCONNECTED = 'onDisconnected';
8463
8501
 
8464
8502
  const MESSAGE_TYPE_CHAT = 'message/TYPE_CHAT';
8465
8503
  const MESSAGE_TYPE_SIGNAL = 'message/TYPE_SIGNAL';
8466
8504
 
8467
- const events$1 = [
8505
+ const events = [
8468
8506
  ON_USER_AGENT,
8469
8507
  ON_REGISTERED,
8470
8508
  ON_UNREGISTERED,
@@ -8481,9 +8519,10 @@ const events$1 = [
8481
8519
  ON_CAMERA_DISABLED,
8482
8520
  ON_CALL_FAILED,
8483
8521
  ON_CALL_ENDED,
8522
+ ON_CALL_REJECTED,
8484
8523
  ON_MESSAGE,
8485
- ON_REINVITE$1,
8486
- ON_TRACK$1,
8524
+ ON_REINVITE,
8525
+ ON_TRACK,
8487
8526
  ON_AUDIO_STREAM,
8488
8527
  ON_VIDEO_STREAM,
8489
8528
  ON_REMOVE_STREAM,
@@ -8498,11 +8537,11 @@ const events$1 = [
8498
8537
  ON_CALL_ERROR,
8499
8538
  ON_CHAT,
8500
8539
  ON_SIGNAL,
8501
- ON_NETWORK_STATS$1,
8502
- ON_DISCONNECTED$1,
8540
+ ON_NETWORK_STATS,
8541
+ ON_DISCONNECTED,
8503
8542
  ];
8504
8543
 
8505
- const logger$4 = IssueReporter$1.loggerFor('webrtc-phone');
8544
+ const logger$8 = IssueReporter$1.loggerFor('webrtc-phone');
8506
8545
 
8507
8546
  class WebRTCPhone extends Emitter {
8508
8547
 
@@ -8575,7 +8614,7 @@ class WebRTCPhone extends Emitter {
8575
8614
  }).catch(error => {
8576
8615
  // Avoid exception on `t.server.scheme` in sip transport when losing the webrtc socket connection
8577
8616
  console.error('register error', error, error.message, error.stack);
8578
- logger$4.error('WebRTC register error', { message: error.message, stack: error.stack });
8617
+ logger$8.error('WebRTC register error', { message: error.message, stack: error.stack });
8579
8618
  });
8580
8619
  }
8581
8620
 
@@ -8590,7 +8629,7 @@ class WebRTCPhone extends Emitter {
8590
8629
  if (!this.client) {
8591
8630
  return;
8592
8631
  }
8593
- logger$4.info('WebRTC phone stop');
8632
+ logger$8.info('WebRTC phone stop');
8594
8633
  this.client.stop();
8595
8634
  }
8596
8635
 
@@ -8605,11 +8644,12 @@ class WebRTCPhone extends Emitter {
8605
8644
  async sendReinvite(callSession , constraints = null, conference = false,
8606
8645
  audioOnly = false, iceRestart = false) {
8607
8646
  const sipSession = this.findSipSession(callSession);
8608
- logger$4.info('WebRTC phone - send reinvite', {
8647
+ logger$8.info('WebRTC phone - send reinvite', {
8609
8648
  sessionId: sipSession ? sipSession.id : null,
8610
8649
  constraints,
8611
8650
  audioOnly,
8612
8651
  conference,
8652
+ iceRestart,
8613
8653
  });
8614
8654
 
8615
8655
  if (!sipSession) {
@@ -8642,7 +8682,7 @@ class WebRTCPhone extends Emitter {
8642
8682
  }
8643
8683
 
8644
8684
  startHeartbeat() {
8645
- logger$4.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8685
+ logger$8.info('WebRTC phone - start heartbeat', { client: !!this.client, hasHeartbeat: this.client.hasHeartbeat() });
8646
8686
  if (!this.client || this.client.hasHeartbeat()) {
8647
8687
  return;
8648
8688
  }
@@ -8651,7 +8691,7 @@ class WebRTCPhone extends Emitter {
8651
8691
  }
8652
8692
 
8653
8693
  stopHeartbeat() {
8654
- logger$4.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8694
+ logger$8.info('WebRTC phone - stopHeartbeat', { client: !!this.client });
8655
8695
  if (!this.client) {
8656
8696
  return;
8657
8697
  }
@@ -8668,7 +8708,7 @@ class WebRTCPhone extends Emitter {
8668
8708
  }
8669
8709
 
8670
8710
  reconnect() {
8671
- logger$4.info('WebRTC phone - reconnect', { client: !!this.client });
8711
+ logger$8.info('WebRTC phone - reconnect', { client: !!this.client });
8672
8712
  if (!this.client) {
8673
8713
  return;
8674
8714
  }
@@ -8709,7 +8749,7 @@ class WebRTCPhone extends Emitter {
8709
8749
  return false;
8710
8750
  }
8711
8751
 
8712
- logger$4.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8752
+ logger$8.info('Downgrade to video', { id: callSession ? callSession.getId() : null, withMessage });
8713
8753
 
8714
8754
  this.client.downgradeToAudio(sipSession);
8715
8755
 
@@ -8732,7 +8772,7 @@ class WebRTCPhone extends Emitter {
8732
8772
  return Promise.resolve(false);
8733
8773
  }
8734
8774
 
8735
- logger$4.info('Upgrade to video', {
8775
+ logger$8.info('Upgrade to video', {
8736
8776
  id: callSession ? callSession.getId() : null,
8737
8777
  constraints,
8738
8778
  isConference,
@@ -8772,7 +8812,7 @@ class WebRTCPhone extends Emitter {
8772
8812
 
8773
8813
  _sendReinviteMessage(callSession , isUpgrade ) {
8774
8814
  const sipSession = this.findSipSession(callSession);
8775
- logger$4.info('Sending reinvite message', {
8815
+ logger$8.info('Sending reinvite message', {
8776
8816
  id: callSession ? callSession.getId() : null,
8777
8817
  isUpgrade,
8778
8818
  });
@@ -8798,7 +8838,7 @@ class WebRTCPhone extends Emitter {
8798
8838
  // Monkey patch to know when canceled with the CANCEL message
8799
8839
  const onCancel = sipSession._onCancel.bind(sipSession);
8800
8840
  sipSession._onCancel = (message ) => {
8801
- logger$4.trace('on sip session canceled', { callId: message.callId });
8841
+ logger$8.trace('on sip session canceled', { callId: message.callId });
8802
8842
 
8803
8843
  onCancel(message);
8804
8844
  const elsewhere = message.data.indexOf('cause=26') !== -1 && message.data.indexOf('completed elsewhere') !== -1;
@@ -8826,16 +8866,17 @@ class WebRTCPhone extends Emitter {
8826
8866
  this.audioOutputVolume,
8827
8867
  );
8828
8868
  case SessionState.Terminating:
8829
- logger$4.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8869
+ logger$8.info('WebRTC phone - call terminating', { sipId: sipSession.id });
8830
8870
 
8831
8871
  this.eventEmitter.emit(ON_CALL_ENDING, this._createCallSession(sipSession));
8832
8872
 
8833
8873
  break;
8834
8874
  case SessionState.Terminated: {
8835
- logger$4.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8875
+ logger$8.info('WebRTC phone - call terminated', { sipId: sipSession.id });
8836
8876
 
8837
8877
  // Should be called before `_onCallTerminated` or the callCount will not decrement...
8838
8878
  const callSession = this._createCallSession(sipSession);
8879
+ callSession.endTime = new Date();
8839
8880
  const wasCurrentSession = this._onCallTerminated(sipSession);
8840
8881
 
8841
8882
  return this.eventEmitter.emit(ON_CALL_ENDED, callSession, wasCurrentSession);
@@ -8854,7 +8895,7 @@ class WebRTCPhone extends Emitter {
8854
8895
  const [stream] = event.streams;
8855
8896
  const kind = event && event.track && event.track.kind;
8856
8897
 
8857
- logger$4.info('on track stream called on the peer connection', {
8898
+ logger$8.info('on track stream called on the peer connection', {
8858
8899
  callId: this.getSipSessionId(sipSession),
8859
8900
  streamId: stream ? stream.id : null,
8860
8901
  tracks: stream ? stream.getTracks() : null,
@@ -8874,7 +8915,7 @@ class WebRTCPhone extends Emitter {
8874
8915
  };
8875
8916
 
8876
8917
  peerConnection.onremovestream = event => {
8877
- logger$4.info('on remove stream called on the peer connection', {
8918
+ logger$8.info('on remove stream called on the peer connection', {
8878
8919
  id: event.stream.id,
8879
8920
  tracks: event.stream.getTracks(),
8880
8921
  });
@@ -8884,7 +8925,7 @@ class WebRTCPhone extends Emitter {
8884
8925
  }
8885
8926
 
8886
8927
  async startScreenSharing(constraints , callSession ) {
8887
- logger$4.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8928
+ logger$8.info('WebRTC - start screen sharing', { constraints, id: callSession ? callSession.getId() : null });
8888
8929
 
8889
8930
  const screenShareStream = await this.client.getStreamFromConstraints(constraints);
8890
8931
  if (!screenShareStream) {
@@ -8924,7 +8965,7 @@ class WebRTCPhone extends Emitter {
8924
8965
  return;
8925
8966
  }
8926
8967
 
8927
- logger$4.info('WebRTC phone - stop screen sharing', {
8968
+ logger$8.info('WebRTC phone - stop screen sharing', {
8928
8969
  restoreLocalStream,
8929
8970
  });
8930
8971
 
@@ -8980,7 +9021,7 @@ class WebRTCPhone extends Emitter {
8980
9021
  const pc = this.client.getPeerConnection(sipSessionId);
8981
9022
  const sender = pc && pc.getSenders().find(s => s && s.track && s.track.kind === 'video');
8982
9023
 
8983
- logger$4.info('WebRTC phone - on screensharing', {
9024
+ logger$8.info('WebRTC phone - on screensharing', {
8984
9025
  hadVideo,
8985
9026
  id: this.getSipSessionId(sipSession),
8986
9027
  screenTrack,
@@ -8988,7 +9029,7 @@ class WebRTCPhone extends Emitter {
8988
9029
 
8989
9030
  if (screenTrack) {
8990
9031
  screenTrack.onended = () => {
8991
- logger$4.info('WebRTC phone - on screenshare ended', {
9032
+ logger$8.info('WebRTC phone - on screenshare ended', {
8992
9033
  hadVideo,
8993
9034
  id: this.getSipSessionId(sipSession),
8994
9035
  screenTrack,
@@ -9019,7 +9060,7 @@ class WebRTCPhone extends Emitter {
9019
9060
  }
9020
9061
 
9021
9062
  _onCallAccepted(sipSession , cameraEnabled ) {
9022
- logger$4.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9063
+ logger$8.info('WebRTC phone - on call accepted', { sipId: sipSession.id, cameraEnabled });
9023
9064
 
9024
9065
  const callSession = this._createAcceptedCallSession(sipSession, cameraEnabled);
9025
9066
  this.currentSipSession = sipSession;
@@ -9037,7 +9078,7 @@ class WebRTCPhone extends Emitter {
9037
9078
  }
9038
9079
 
9039
9080
  changeAudioDevice(id ) {
9040
- logger$4.info('WebRTC phone - change audio device', { deviceId: id });
9081
+ logger$8.info('WebRTC phone - change audio device', { deviceId: id });
9041
9082
  this.audioOutputDeviceId = id;
9042
9083
  this.client.changeAudioOutputDevice(id);
9043
9084
  }
@@ -9047,14 +9088,14 @@ class WebRTCPhone extends Emitter {
9047
9088
  }
9048
9089
 
9049
9090
  changeRingDevice(id ) {
9050
- logger$4.info('WebRTC phone - changing ring device', { id });
9091
+ logger$8.info('WebRTC phone - changing ring device', { id });
9051
9092
 
9052
9093
  this.audioRingDeviceId = id;
9053
9094
  }
9054
9095
 
9055
9096
  // volume is a value between 0 and 1
9056
9097
  changeAudioVolume(volume ) {
9057
- logger$4.info('WebRTC phone - changing audio volume', { volume });
9098
+ logger$8.info('WebRTC phone - changing audio volume', { volume });
9058
9099
 
9059
9100
  this.audioOutputVolume = volume;
9060
9101
  this.client.changeAudioOutputVolume(volume);
@@ -9062,32 +9103,33 @@ class WebRTCPhone extends Emitter {
9062
9103
 
9063
9104
  // volume is a value between 0 and 1
9064
9105
  changeRingVolume(volume ) {
9065
- logger$4.info('WebRTC phone - changing ring volume', { volume });
9106
+ logger$8.info('WebRTC phone - changing ring volume', { volume });
9066
9107
 
9067
9108
  this.audioRingVolume = volume;
9068
9109
  }
9069
9110
 
9070
9111
  changeAudioInputDevice(id ) {
9071
- logger$4.info('WebRTC phone - changeAudio input device', { deviceId: id });
9112
+ logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9072
9113
 
9073
9114
  return this.client.changeAudioInputDevice(id, this.currentSipSession);
9074
9115
  }
9075
9116
 
9076
9117
  changeVideoInputDevice(id ) {
9077
- logger$4.info('WebRTC phone - change video input device', { deviceId: id });
9118
+ logger$8.info('WebRTC phone - change video input device', { deviceId: id });
9078
9119
 
9079
9120
  return this.client.changeVideoInputDevice(id, this.currentSipSession);
9080
9121
  }
9081
9122
 
9082
9123
  changeSessionVideoInputDevice(id ) {
9083
- logger$4.info('WebRTC phone - change session video input device', { deviceId: id });
9124
+ logger$8.info('WebRTC phone - change session video input device', { deviceId: id });
9084
9125
 
9085
9126
  return this.client.changeSessionVideoInputDevice(id, this.currentSipSession);
9086
9127
  }
9087
9128
 
9088
9129
  _onCallTerminated(sipSession ) {
9089
- logger$4.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9130
+ logger$8.info('WebRTC phone - on call terminated', { sipId: sipSession.id });
9090
9131
 
9132
+ const sipSessionId = this.getSipSessionId(sipSession);
9091
9133
  const callSession = this._createCallSession(sipSession);
9092
9134
  const isCurrentSession = this.isCurrentCallSipSession(callSession);
9093
9135
  const isCurrentIncomingCall = callSession.is(this.getIncomingCallSession());
@@ -9105,7 +9147,6 @@ class WebRTCPhone extends Emitter {
9105
9147
  }, 5);
9106
9148
  }
9107
9149
 
9108
- const sipSessionId = this.getSipSessionId(sipSession);
9109
9150
  if (sipSessionId) {
9110
9151
  this.removeIncomingSessions(sipSessionId);
9111
9152
  }
@@ -9120,7 +9161,7 @@ class WebRTCPhone extends Emitter {
9120
9161
  const hasIncomingCallSession = this.hasIncomingCallSession();
9121
9162
 
9122
9163
  // Re-trigger incoming call event for remaining incoming calls
9123
- logger$4.info('WebRTC phone - check to re-trigger incoming call', {
9164
+ logger$8.info('WebRTC phone - check to re-trigger incoming call', {
9124
9165
  sipId: sipSession.id,
9125
9166
  shouldRetrigger,
9126
9167
  hasIncomingCallSession,
@@ -9211,37 +9252,37 @@ class WebRTCPhone extends Emitter {
9211
9252
 
9212
9253
  // Deprecated
9213
9254
  getLocalStreamForCall(callSession ) {
9214
- logger$4.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9255
+ logger$8.warn('WebRTCPhone.getLocalStreamForCall is deprecated, use WebRTCPhone.getLocalStream instead');
9215
9256
 
9216
9257
  return this.getLocalStream(callSession);
9217
9258
  }
9218
9259
 
9219
9260
  // Deprecated
9220
9261
  getRemoteStreamForCall(callSession ) {
9221
- logger$4.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9262
+ logger$8.warn('WebRTCPhone.getRemoteStreamForCall is deprecated, use WebRTCPhone.getRemoteStream instead');
9222
9263
 
9223
9264
  return this.getRemoteVideoStream(callSession);
9224
9265
  }
9225
9266
 
9226
9267
  getRemoteStreamsForCall(callSession ) {
9227
- logger$4.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9268
+ logger$8.warn('WebRTCPhone.getRemoteStreamsForCall is deprecated, use WebRTCPhone.getRemoteStreams instead');
9228
9269
 
9229
9270
  return this.getRemoteStream(callSession);
9230
9271
  }
9231
9272
 
9232
9273
  accept(callSession , cameraEnabled ) {
9233
- logger$4.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9274
+ logger$8.info('WebRTC phone - accept call', { id: callSession ? callSession.getId() : 'n/a', cameraEnabled });
9234
9275
  if (this.currentSipSession) {
9235
9276
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true);
9236
9277
  }
9237
9278
 
9238
9279
  if (!callSession) {
9239
- logger$4.warn('no CallSession to accept.');
9280
+ logger$8.warn('no CallSession to accept.');
9240
9281
  return Promise.resolve(null);
9241
9282
  }
9242
9283
 
9243
9284
  if (callSession.getId() in this.acceptedSessions) {
9244
- logger$4.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9285
+ logger$8.warn('CallSession already accepted.', { id: callSession ? callSession.getId() : 'n/a' });
9245
9286
  return Promise.resolve(callSession.sipCallId);
9246
9287
  }
9247
9288
 
@@ -9253,24 +9294,24 @@ class WebRTCPhone extends Emitter {
9253
9294
  const sipSession = this.client.getSipSession(callSession.getId());
9254
9295
  if (sipSession) {
9255
9296
  if (sipSession.state === SessionState.Terminated || sipSession.state === SessionState.Terminating) {
9256
- logger$4.warn('Trying to answer a terminated sipSession.');
9297
+ logger$8.warn('Trying to answer a terminated sipSession.');
9257
9298
 
9258
9299
  return Promise.resolve(null);
9259
9300
  }
9260
9301
 
9261
- logger$4.info('accept call, session found', { sipId: sipSession.id });
9302
+ logger$8.info('accept call, session found', { sipId: sipSession.id });
9262
9303
 
9263
9304
  // $FlowFixMe
9264
9305
  return this.client.answer(sipSession, this.allowVideo ? cameraEnabled : false).then(() => {
9265
9306
  return callSession.sipCallId;
9266
9307
  }).catch(e => {
9267
- logger$4.error(e);
9308
+ logger$8.error(e);
9268
9309
  this.endCurrentCall(callSession);
9269
9310
  throw e;
9270
9311
  });
9271
9312
  }
9272
9313
 
9273
- logger$4.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9314
+ logger$8.warn('no CallSession found to accept.', { id: callSession ? callSession.getId() : 'n/a' });
9274
9315
 
9275
9316
  return Promise.resolve(null);
9276
9317
  }
@@ -9280,7 +9321,7 @@ class WebRTCPhone extends Emitter {
9280
9321
  }
9281
9322
 
9282
9323
  async reject(callSession ) {
9283
- logger$4.info('reject WebRTC called', { id: callSession.getId() });
9324
+ logger$8.info('reject WebRTC called', { id: callSession.getId() });
9284
9325
 
9285
9326
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'call rejected locally');
9286
9327
  if (!callSession || callSession.getId() in this.rejectedSessions) {
@@ -9292,14 +9333,14 @@ class WebRTCPhone extends Emitter {
9292
9333
 
9293
9334
  const sipSession = this.findSipSession(callSession);
9294
9335
  if (sipSession) {
9295
- logger$4.info('WebRTC rejecting', { sipId: sipSession.id });
9336
+ logger$8.info('WebRTC rejecting', { sipId: sipSession.id });
9296
9337
 
9297
9338
  this.client.hangup(sipSession);
9298
9339
  }
9299
9340
  }
9300
9341
 
9301
9342
  async ignore(callSession ) {
9302
- logger$4.info('WebRTC ignore', { id: callSession.getId() });
9343
+ logger$8.info('WebRTC ignore', { id: callSession.getId() });
9303
9344
 
9304
9345
  // kill the ring
9305
9346
  this.eventEmitter.emit(ON_TERMINATE_SOUND, callSession, 'ignoring call');
@@ -9311,14 +9352,14 @@ class WebRTCPhone extends Emitter {
9311
9352
  const sipSession = this.findSipSession(callSession);
9312
9353
 
9313
9354
  if (sipSession) {
9314
- logger$4.info('WebRTC atxfer', { sipId: sipSession.id });
9355
+ logger$8.info('WebRTC atxfer', { sipId: sipSession.id });
9315
9356
 
9316
9357
  return this.client.atxfer(sipSession);
9317
9358
  }
9318
9359
  }
9319
9360
 
9320
9361
  hold(callSession , withEvent = true, isConference = false) {
9321
- logger$4.info('WebRTC hold', { id: callSession.getId() });
9362
+ logger$8.info('WebRTC hold', { id: callSession.getId() });
9322
9363
 
9323
9364
  const sipSession = this.findSipSession(callSession);
9324
9365
 
@@ -9333,18 +9374,18 @@ class WebRTCPhone extends Emitter {
9333
9374
  }
9334
9375
 
9335
9376
  resume(callSession , isConference = false, withEvent = true) {
9336
- logger$4.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9377
+ logger$8.info('WebRTC resume called', { id: callSession ? callSession.getId() : null });
9337
9378
 
9338
9379
  const sipSession = this.findSipSession(callSession);
9339
9380
  if (!sipSession) {
9340
9381
  return new Promise((resolve, reject) => reject(new Error('No session to resume')));
9341
9382
  }
9342
9383
 
9343
- logger$4.info('WebRTC resuming', { sipId: sipSession.id });
9384
+ logger$8.info('WebRTC resuming', { sipId: sipSession.id });
9344
9385
 
9345
9386
  // Hold current session if different from the current one (we don't want 2 sessions active at the same time).
9346
9387
  if (this.currentSipSession && this.currentSipSession.id !== sipSession.id) {
9347
- logger$4.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9388
+ logger$8.info('WebRTC hold call after resume', { id: this.currentSipSession.id });
9348
9389
  this.holdSipSession(this.currentSipSession, callSession);
9349
9390
  }
9350
9391
 
@@ -9369,7 +9410,7 @@ class WebRTCPhone extends Emitter {
9369
9410
  const sessionId = this.getSipSessionId(sipSession);
9370
9411
  const hasVideo = this.client.hasLocalVideo(sessionId);
9371
9412
 
9372
- logger$4.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9413
+ logger$8.info('WebRTC hold sip session', { sipId: sipSession.id, hasVideo });
9373
9414
 
9374
9415
  // Stop screenshre if needed
9375
9416
  if (this.currentScreenShare && this.currentScreenShare.sipSessionId === sessionId) {
@@ -9400,7 +9441,7 @@ class WebRTCPhone extends Emitter {
9400
9441
  return new Promise((resolve, reject) => reject(new Error('No session to unhold')));
9401
9442
  }
9402
9443
  const sessionId = this.getSipSessionId(sipSession);
9403
- logger$4.info('WebRTC unhold sip session', { sessionId, isConference });
9444
+ logger$8.info('WebRTC unhold sip session', { sessionId, isConference });
9404
9445
 
9405
9446
  const { hasVideo } = this.client.getHeldSession(sessionId) || {};
9406
9447
  const wasScreensharing = this.lastScreenShare && this.lastScreenShare.sipSessionId === sessionId;
@@ -9444,14 +9485,14 @@ class WebRTCPhone extends Emitter {
9444
9485
  }
9445
9486
 
9446
9487
  mute(callSession , withEvent = true) {
9447
- logger$4.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9488
+ logger$8.info('WebRTC mute called', { id: callSession ? callSession.getId() : null });
9448
9489
 
9449
9490
  const sipSession = this.findSipSession(callSession);
9450
9491
  if (!sipSession) {
9451
9492
  return;
9452
9493
  }
9453
9494
 
9454
- logger$4.info('WebRTC muting', { sipId: sipSession.id });
9495
+ logger$8.info('WebRTC muting', { sipId: sipSession.id });
9455
9496
  this.client.mute(sipSession);
9456
9497
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: true });
9457
9498
 
@@ -9465,14 +9506,14 @@ class WebRTCPhone extends Emitter {
9465
9506
  }
9466
9507
 
9467
9508
  unmute(callSession , withEvent = true) {
9468
- logger$4.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9509
+ logger$8.info('WebRTC unmute called', { id: callSession ? callSession.getId() : null });
9469
9510
 
9470
9511
  const sipSession = this.findSipSession(callSession);
9471
9512
  if (!sipSession) {
9472
9513
  return;
9473
9514
  }
9474
9515
 
9475
- logger$4.info('WebRTC unmuting', { sipId: sipSession.id });
9516
+ logger$8.info('WebRTC unmuting', { sipId: sipSession.id });
9476
9517
  this.client.unmute(sipSession);
9477
9518
  const newCallSession = this._createCallSession(sipSession, callSession, { muted: false });
9478
9519
 
@@ -9499,7 +9540,7 @@ class WebRTCPhone extends Emitter {
9499
9540
  if (!sipSession) {
9500
9541
  return;
9501
9542
  }
9502
- logger$4.info('WebRTC turn camera on', { sipId: sipSession.id });
9543
+ logger$8.info('WebRTC turn camera on', { sipId: sipSession.id });
9503
9544
 
9504
9545
  this.client.toggleCameraOn(sipSession);
9505
9546
 
@@ -9511,7 +9552,7 @@ class WebRTCPhone extends Emitter {
9511
9552
  if (!sipSession) {
9512
9553
  return;
9513
9554
  }
9514
- logger$4.info('WebRTC turn camera off', { sipId: sipSession.id });
9555
+ logger$8.info('WebRTC turn camera off', { sipId: sipSession.id });
9515
9556
 
9516
9557
  this.client.toggleCameraOff(sipSession);
9517
9558
  this.eventEmitter.emit(ON_CAMERA_DISABLED, this._createCameraDisabledCallSession(sipSession, callSession));
@@ -9523,7 +9564,7 @@ class WebRTCPhone extends Emitter {
9523
9564
  return;
9524
9565
  }
9525
9566
 
9526
- logger$4.info('WebRTC send key', { sipId: sipSession.id, tone });
9567
+ logger$8.info('WebRTC send key', { sipId: sipSession.id, tone });
9527
9568
  this.client.sendDTMF(sipSession, tone);
9528
9569
  }
9529
9570
 
@@ -9531,7 +9572,7 @@ class WebRTCPhone extends Emitter {
9531
9572
  // @TODO: line is not used here
9532
9573
  async makeCall(number , line , cameraEnabled ,
9533
9574
  audioOnly = false, conference = false) {
9534
- logger$4.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled });
9575
+ logger$8.info('make WebRTC call', { number, lineId: line ? line.id : null, cameraEnabled, audioOnly, conference });
9535
9576
  if (!number) {
9536
9577
  return Promise.resolve(null);
9537
9578
  }
@@ -9541,7 +9582,7 @@ class WebRTCPhone extends Emitter {
9541
9582
  }
9542
9583
  if (this.currentSipSession) {
9543
9584
  this.holdSipSession(this.currentSipSession, this.currentCallSession, true).catch(e => {
9544
- logger$4.warn('Unable to hold current session when making another call', e);
9585
+ logger$8.warn('Unable to hold current session when making another call', e);
9545
9586
  });
9546
9587
  }
9547
9588
 
@@ -9551,10 +9592,11 @@ class WebRTCPhone extends Emitter {
9551
9592
  this._bindEvents(sipSession);
9552
9593
  } catch (error) {
9553
9594
  console.warn(error);
9554
- logger$4.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9595
+ logger$8.warn('make WebRTC call, error', { message: error.message, stack: error.stack });
9555
9596
  return Promise.resolve(null);
9556
9597
  }
9557
9598
  const callSession = this._createOutgoingCallSession(sipSession, cameraEnabled || false);
9599
+ callSession.creationTime = new Date();
9558
9600
 
9559
9601
  this.eventEmitter.emit(ON_PLAY_PROGRESS_SOUND, this.audioOutputDeviceId, this.audioOutputVolume);
9560
9602
 
@@ -9579,7 +9621,7 @@ class WebRTCPhone extends Emitter {
9579
9621
  return;
9580
9622
  }
9581
9623
 
9582
- logger$4.info('WebRTC transfer', { sipId: sipSession.id, target });
9624
+ logger$8.info('WebRTC transfer', { sipId: sipSession.id, target });
9583
9625
 
9584
9626
  this.client.transfer(sipSession, target);
9585
9627
  }
@@ -9588,7 +9630,7 @@ class WebRTCPhone extends Emitter {
9588
9630
  const sipSession = this.client.getSipSession(source.sipCallId);
9589
9631
  const sipSessionTarget = this.client.getSipSession(destination.sipCallId);
9590
9632
 
9591
- logger$4.info('WebRTC indirect transfer', {
9633
+ logger$8.info('WebRTC indirect transfer', {
9592
9634
  sipId: sipSession ? sipSession.id : null,
9593
9635
  target: sipSessionTarget ? sipSessionTarget.id : null,
9594
9636
  });
@@ -9627,7 +9669,7 @@ class WebRTCPhone extends Emitter {
9627
9669
  return false;
9628
9670
  }
9629
9671
 
9630
- logger$4.info('WebRTC hangup', { sipId: sipSession.id });
9672
+ logger$8.info('WebRTC hangup', { sipId: sipSession.id });
9631
9673
 
9632
9674
  const sipSessionId = this.getSipSessionId(sipSession);
9633
9675
 
@@ -9673,7 +9715,7 @@ class WebRTCPhone extends Emitter {
9673
9715
  endCurrentCall(callSession ) {
9674
9716
  const isCurrent = this.isCurrentCallSipSession(callSession);
9675
9717
 
9676
- logger$4.info('Ending current call', {
9718
+ logger$8.info('Ending current call', {
9677
9719
  id: callSession ? callSession.getId() : null,
9678
9720
  isCurrent,
9679
9721
  });
@@ -9697,7 +9739,7 @@ class WebRTCPhone extends Emitter {
9697
9739
  }
9698
9740
 
9699
9741
  async close() {
9700
- logger$4.info('WebRTC close');
9742
+ logger$8.info('WebRTC close');
9701
9743
 
9702
9744
  try {
9703
9745
  await Promise.race([
@@ -9705,7 +9747,7 @@ class WebRTCPhone extends Emitter {
9705
9747
  new Promise((resolve, reject) => setTimeout(() => reject(new Error('Unregister, timed out')), 3000)),
9706
9748
  ]);
9707
9749
  } catch (e) {
9708
- logger$4.error('WebRTC close, unregister error', e);
9750
+ logger$8.error('WebRTC close, unregister error', e);
9709
9751
  }
9710
9752
 
9711
9753
  this.client.close();
@@ -9723,12 +9765,12 @@ class WebRTCPhone extends Emitter {
9723
9765
  }
9724
9766
 
9725
9767
  enableRinging() {
9726
- logger$4.info('WebRTC enable ringing');
9768
+ logger$8.info('WebRTC enable ringing');
9727
9769
  this.ringingEnabled = true;
9728
9770
  }
9729
9771
 
9730
9772
  disableRinging() {
9731
- logger$4.info('WebRTC disable ringing');
9773
+ logger$8.info('WebRTC disable ringing');
9732
9774
  this.ringingEnabled = false;
9733
9775
  }
9734
9776
 
@@ -9750,8 +9792,12 @@ class WebRTCPhone extends Emitter {
9750
9792
  }
9751
9793
 
9752
9794
  const sessionId = this.incomingSessions[0];
9795
+ const sipSession = this.client.getSipSession(sessionId);
9796
+ if (!sipSession) {
9797
+ return null;
9798
+ }
9753
9799
 
9754
- return this._createCallSession(this.client.getSipSession(sessionId));
9800
+ return this._createCallSession(sipSession);
9755
9801
  }
9756
9802
 
9757
9803
  sendMessage(sipSession = null, body , contentType = 'text/plain') {
@@ -9768,7 +9814,7 @@ class WebRTCPhone extends Emitter {
9768
9814
 
9769
9815
  // Deprecated
9770
9816
  getLocalMediaStream(callSession ) {
9771
- logger$4.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9817
+ logger$8.warn('WebRTCPhone.getLocalMediaStream is deprecated, use WebRTCPhone.getLocalStream instead');
9772
9818
  return this.getLocalStream(callSession);
9773
9819
  }
9774
9820
 
@@ -9810,7 +9856,7 @@ class WebRTCPhone extends Emitter {
9810
9856
  this.client.on(this.client.INVITE, (sipSession , wantsToDoVideo ) => {
9811
9857
  const autoAnswer = sipSession.request.getHeader('Answer-Mode') === 'Auto';
9812
9858
  const withVideo = this.allowVideo ? wantsToDoVideo : false;
9813
- logger$4.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9859
+ logger$8.info('WebRTC invite received', { sipId: sipSession.id, withVideo, autoAnswer });
9814
9860
 
9815
9861
  const callSession = this._createIncomingCallSession(sipSession, withVideo, null, autoAnswer);
9816
9862
  this.incomingSessions.push(callSession.getId());
@@ -9829,11 +9875,12 @@ class WebRTCPhone extends Emitter {
9829
9875
  callSession);
9830
9876
  }
9831
9877
 
9878
+ callSession.creationTime = new Date();
9832
9879
  this.eventEmitter.emit(ON_CALL_INCOMING, callSession, wantsToDoVideo);
9833
9880
  });
9834
9881
 
9835
9882
  this.client.on(this.client.ON_REINVITE, (...args) => {
9836
- logger$4.info('WebRTC on reinvite', {
9883
+ logger$8.info('WebRTC on reinvite', {
9837
9884
  sessionId: args[0].id,
9838
9885
  inviteId: args[1].id,
9839
9886
  updatedCalleeName: args[2],
@@ -9853,7 +9900,7 @@ class WebRTCPhone extends Emitter {
9853
9900
  });
9854
9901
 
9855
9902
  this.client.on(this.client.ACCEPTED, (sipSession ) => {
9856
- logger$4.info('WebRTC call accepted', { sipId: sipSession.id });
9903
+ logger$8.info('WebRTC call accepted', { sipId: sipSession.id });
9857
9904
 
9858
9905
  this._onCallAccepted(sipSession, this.client.hasVideo(this.getSipSessionId(sipSession)));
9859
9906
 
@@ -9864,22 +9911,29 @@ class WebRTCPhone extends Emitter {
9864
9911
  this.client.on('ended', () => {});
9865
9912
 
9866
9913
  this.client.on(this.client.ON_ERROR, e => {
9867
- logger$4.error('WebRTC error', e);
9914
+ logger$8.error('WebRTC error', e);
9868
9915
  this.eventEmitter.emit(ON_CALL_ERROR, e);
9869
9916
  });
9870
9917
 
9918
+ this.client.on(this.client.REJECTED, session => {
9919
+ logger$8.info('WebRTC call rejected', session.id);
9920
+ const callSession = this._createCallSession(session);
9921
+ callSession.endTime = new Date();
9922
+ this.eventEmitter.emit(ON_CALL_REJECTED, callSession);
9923
+ });
9924
+
9871
9925
  this.client.on(this.client.UNREGISTERED, () => {
9872
- logger$4.info('WebRTC unregistered');
9926
+ logger$8.info('WebRTC unregistered');
9873
9927
  this.eventEmitter.emit(ON_UNREGISTERED);
9874
9928
  });
9875
9929
 
9876
9930
  this.client.on(this.client.ON_DISCONNECTED, () => {
9877
- logger$4.info('WebRTC disconnected');
9878
- this.eventEmitter.emit(ON_DISCONNECTED$1);
9931
+ logger$8.info('WebRTC disconnected');
9932
+ this.eventEmitter.emit(ON_DISCONNECTED);
9879
9933
  });
9880
9934
 
9881
9935
  this.client.on(this.client.REGISTERED, () => {
9882
- logger$4.info('WebRTC registered', {
9936
+ logger$8.info('WebRTC registered', {
9883
9937
  shouldSendReinvite: this.shouldSendReinvite,
9884
9938
  state: this.currentSipSession ? this.currentSipSession.state : null,
9885
9939
  currentSipSession: !!this.currentSipSession,
@@ -9900,19 +9954,19 @@ class WebRTCPhone extends Emitter {
9900
9954
  // Send reinvite with iceRestart
9901
9955
  this.sendReinvite(this.currentCallSession, null, isConference, !hasVideo, true);
9902
9956
  } catch (e) {
9903
- logger$4.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9957
+ logger$8.error('WebRTC reinvite after register, error', { message: e.message, stack: e.stack });
9904
9958
  }
9905
9959
  }
9906
9960
  });
9907
9961
 
9908
9962
  this.client.on(this.client.CONNECTED, () => {
9909
- logger$4.info('WebRTC client connected');
9963
+ logger$8.info('WebRTC client connected');
9910
9964
 
9911
9965
  this.stopHeartbeat();
9912
9966
  });
9913
9967
 
9914
9968
  this.client.on(this.client.DISCONNECTED, () => {
9915
- logger$4.info('WebRTC client disconnected');
9969
+ logger$8.info('WebRTC client disconnected');
9916
9970
 
9917
9971
  this.eventEmitter.emit(ON_UNREGISTERED);
9918
9972
 
@@ -9926,7 +9980,7 @@ class WebRTCPhone extends Emitter {
9926
9980
  });
9927
9981
 
9928
9982
  this.client.on(this.client.ON_TRACK, (session, event) => {
9929
- this.eventEmitter.emit(ON_TRACK$1, session, event);
9983
+ this.eventEmitter.emit(ON_TRACK, session, event);
9930
9984
  });
9931
9985
 
9932
9986
  this.client.on('onVideoInputChange', stream => {
@@ -9941,7 +9995,7 @@ class WebRTCPhone extends Emitter {
9941
9995
  this.client.on(this.client.ON_NETWORK_STATS, (session, stats, previousStats) => {
9942
9996
  const callSession = this.getCallSession(this.getSipSessionId(session));
9943
9997
 
9944
- this.eventEmitter.emit(ON_NETWORK_STATS$1, callSession, stats, previousStats);
9998
+ this.eventEmitter.emit(ON_NETWORK_STATS, callSession, stats, previousStats);
9945
9999
  });
9946
10000
 
9947
10001
  // Used when upgrading directly in screenshare mode
@@ -9950,7 +10004,7 @@ class WebRTCPhone extends Emitter {
9950
10004
  const localStream = this.client.getLocalStream(sipSessionId);
9951
10005
  const callSession = this.callSessions[sipSessionId];
9952
10006
 
9953
- logger$4.info('Updrading directly in screensharing mode', {
10007
+ logger$8.info('Updrading directly in screensharing mode', {
9954
10008
  sipSessionId,
9955
10009
  tracks: localStream ? localStream.getTracks() : null,
9956
10010
  });
@@ -10080,6 +10134,7 @@ class WebRTCPhone extends Emitter {
10080
10134
  const number = identity ? identity.uri._normal.user : null;
10081
10135
  const { state } = sipSession || {};
10082
10136
  const sessionId = this.getSipSessionId(sipSession);
10137
+ fromSession = fromSession || this.callSessions[sessionId];
10083
10138
 
10084
10139
  const callSession = new CallSession({
10085
10140
  callId: fromSession && fromSession.callId,
@@ -10087,6 +10142,8 @@ class WebRTCPhone extends Emitter {
10087
10142
  sipStatus: state,
10088
10143
  displayName: identity ? identity.displayName || number : number,
10089
10144
  startTime: fromSession ? fromSession.startTime : new Date(),
10145
+ creationTime: fromSession ? fromSession.creationTime : null,
10146
+ endTime: fromSession ? fromSession.endTime : null,
10090
10147
  answered: state === SessionState.Established,
10091
10148
  paused: this.client.isCallHeld(sipSession),
10092
10149
  isCaller: 'incoming' in extra ? !extra.incoming : false,
@@ -10097,6 +10154,7 @@ class WebRTCPhone extends Emitter {
10097
10154
  videoMuted: fromSession ? fromSession.isVideoMuted() : false,
10098
10155
  recording: fromSession ? fromSession.isRecording() : false,
10099
10156
  recordingPaused: false, // @TODO
10157
+ sipSession,
10100
10158
  ...extra,
10101
10159
  });
10102
10160
 
@@ -10125,11 +10183,12 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10125
10183
  ON_CAMERA_RESUMED: ON_CAMERA_RESUMED,
10126
10184
  ON_CALL_CANCELED: ON_CALL_CANCELED,
10127
10185
  ON_CALL_FAILED: ON_CALL_FAILED,
10186
+ ON_CALL_REJECTED: ON_CALL_REJECTED,
10128
10187
  ON_CALL_ENDED: ON_CALL_ENDED,
10129
10188
  ON_CALL_ENDING: ON_CALL_ENDING,
10130
10189
  ON_MESSAGE: ON_MESSAGE,
10131
- ON_REINVITE: ON_REINVITE$1,
10132
- ON_TRACK: ON_TRACK$1,
10190
+ ON_REINVITE: ON_REINVITE,
10191
+ ON_TRACK: ON_TRACK,
10133
10192
  ON_AUDIO_STREAM: ON_AUDIO_STREAM,
10134
10193
  ON_VIDEO_STREAM: ON_VIDEO_STREAM,
10135
10194
  ON_REMOVE_STREAM: ON_REMOVE_STREAM,
@@ -10144,19 +10203,27 @@ var PHONE_EVENTS = /*#__PURE__*/Object.freeze({
10144
10203
  ON_VIDEO_INPUT_CHANGE: ON_VIDEO_INPUT_CHANGE,
10145
10204
  ON_CALL_ERROR: ON_CALL_ERROR,
10146
10205
  ON_MESSAGE_TRACK_UPDATED: ON_MESSAGE_TRACK_UPDATED,
10147
- ON_NETWORK_STATS: ON_NETWORK_STATS$1,
10206
+ ON_NETWORK_STATS: ON_NETWORK_STATS,
10148
10207
  ON_CHAT: ON_CHAT,
10149
10208
  ON_SIGNAL: ON_SIGNAL,
10150
- ON_DISCONNECTED: ON_DISCONNECTED$1,
10209
+ ON_DISCONNECTED: ON_DISCONNECTED,
10151
10210
  MESSAGE_TYPE_CHAT: MESSAGE_TYPE_CHAT,
10152
10211
  MESSAGE_TYPE_SIGNAL: MESSAGE_TYPE_SIGNAL,
10153
- events: events$1,
10212
+ events: events,
10154
10213
  'default': WebRTCPhone
10155
10214
  });
10156
10215
 
10216
+ /* */
10217
+ class SFUNotAvailableError extends Error {
10218
+ constructor(message = 'Sorry your user is not configured to support video conference') {
10219
+ super(message);
10220
+ this.name = 'SFUNotAvailableError';
10221
+ }
10222
+ }
10223
+
10157
10224
  //
10158
10225
 
10159
- const logger$5 = IssueReporter$1.loggerFor('simple-phone');
10226
+ const logger$7 = IssueReporter$1.loggerFor('simple-phone');
10160
10227
  const sipLogger = IssueReporter$1.loggerFor('sip.js');
10161
10228
  const protocolLogger = IssueReporter$1.loggerFor('sip');
10162
10229
 
@@ -10263,7 +10330,7 @@ class Phone extends Emitter {
10263
10330
  async disconnect() {
10264
10331
  if (this.phone) {
10265
10332
  if (this.phone.hasAnActiveCall()) {
10266
- logger$5.info('hangup call on disconnect');
10333
+ logger$7.info('hangup call on disconnect');
10267
10334
  // $FlowFixMe
10268
10335
  await this.phone.hangup();
10269
10336
  }
@@ -10286,13 +10353,13 @@ class Phone extends Emitter {
10286
10353
  }
10287
10354
 
10288
10355
  async hangup(callSession ) {
10289
- logger$5.info('hangup via simple phone', { callId: callSession.getId() });
10356
+ logger$7.info('hangup via simple phone', { callId: callSession.getId() });
10290
10357
 
10291
10358
  return this.phone && this.phone.hangup(callSession);
10292
10359
  }
10293
10360
 
10294
10361
  async accept(callSession , cameraEnabled ) {
10295
- logger$5.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10362
+ logger$7.info('accept via simple phone', { callId: callSession.getId(), cameraEnabled });
10296
10363
 
10297
10364
  return this.phone && this.phone.accept(callSession, cameraEnabled);
10298
10365
  }
@@ -10331,7 +10398,7 @@ class Phone extends Emitter {
10331
10398
  muteViaAPI(callSession ) {
10332
10399
  if (callSession && callSession.callId) {
10333
10400
  Wazo.getApiClient().calld.mute(callSession.callId).catch(e => {
10334
- logger$5.error('Mute via API, error', e);
10401
+ logger$7.error('Mute via API, error', e);
10335
10402
  });
10336
10403
  }
10337
10404
  }
@@ -10339,7 +10406,7 @@ class Phone extends Emitter {
10339
10406
  unmuteViaAPI(callSession ) {
10340
10407
  if (callSession && callSession.callId) {
10341
10408
  Wazo.getApiClient().calld.unmute(callSession.callId).catch(e => {
10342
- logger$5.error('Unmute via API, error', e);
10409
+ logger$7.error('Unmute via API, error', e);
10343
10410
  });
10344
10411
  }
10345
10412
  }
@@ -10447,7 +10514,7 @@ class Phone extends Emitter {
10447
10514
 
10448
10515
  // @Deprecated
10449
10516
  getLocalMediaStream(callSession ) {
10450
- logger$5.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10517
+ logger$7.warn('Phone.getLocalMediaStream is deprecated, use Phone.getLocalStream instead');
10451
10518
 
10452
10519
  return this.phone && this.phone.getLocalStream(callSession);
10453
10520
  }
@@ -10470,20 +10537,20 @@ class Phone extends Emitter {
10470
10537
 
10471
10538
  // @Deprecated
10472
10539
  getRemoteStreamForCall(callSession ) {
10473
- logger$5.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10540
+ logger$7.warn('Phone.getRemoteStreamForCall is deprecated, use Phone.getRemoteStream instead');
10474
10541
  return this.getRemoteStream(callSession);
10475
10542
  }
10476
10543
 
10477
10544
  // Returns remote streams directly from the peerConnection
10478
10545
  // @Deprecated
10479
10546
  getRemoteStreamsForCall(callSession ) {
10480
- logger$5.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10547
+ logger$7.warn('Phone.getRemoteStreamsForCall is deprecated, use Phone.getLocalStream instead');
10481
10548
  return this.getLocalStream(callSession);
10482
10549
  }
10483
10550
 
10484
10551
  // @Deprecated
10485
10552
  getRemoteVideoStreamForCall(callSession ) {
10486
- logger$5.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10553
+ logger$7.warn('Phone.getRemoteVideoStreamForCall is deprecated, use Phone.getRemoteVideoStream instead');
10487
10554
 
10488
10555
  return this.getRemoteVideoStream(callSession);
10489
10556
  }
@@ -10538,13 +10605,13 @@ class Phone extends Emitter {
10538
10605
 
10539
10606
  checkSfu() {
10540
10607
  if (!this.hasSfu()) {
10541
- throw new Error('Sorry your user is not configured to support video conference');
10608
+ throw new SFUNotAvailableError();
10542
10609
  }
10543
10610
  }
10544
10611
 
10545
10612
  _transferEvents() {
10546
10613
  this.unbind();
10547
- [...events, ...transportEvents].forEach(event => {
10614
+ [...events$1, ...transportEvents].forEach(event => {
10548
10615
  this.client.on(event, (...args) =>
10549
10616
  this.eventEmitter.emit.apply(this.eventEmitter.emit, [`client-${event}`, ...args]));
10550
10617
  });
@@ -10566,7 +10633,7 @@ var Phone$1 = global.wazoTelephonyInstance;
10566
10633
 
10567
10634
  //
10568
10635
 
10569
- const SOCKET_EVENTS = {
10636
+ const SOCKET_EVENTS$1 = {
10570
10637
  ON_OPEN: 'onopen',
10571
10638
  ON_MESSAGE: 'onmessage',
10572
10639
  ON_ERROR: 'onerror',
@@ -10719,16 +10786,16 @@ class WebSocketClient extends Emitter {
10719
10786
 
10720
10787
  this.socket.onopen = () => {
10721
10788
  logger$6.info('on Wazo WS open', { method: 'connect', host: this.host });
10722
- this.eventEmitter.emit(SOCKET_EVENTS.ON_OPEN);
10789
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_OPEN);
10723
10790
  };
10724
10791
 
10725
10792
  this.socket.onerror = event => {
10726
10793
  logger$6.error('on Wazo WS error', event.target);
10727
- this.eventEmitter.emit(SOCKET_EVENTS.ON_ERROR, event);
10794
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_ERROR, event);
10728
10795
  };
10729
10796
 
10730
10797
  this.socket.onmessage = (event ) => {
10731
- this.eventEmitter.emit(SOCKET_EVENTS.ON_MESSAGE, event.data);
10798
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_MESSAGE, event.data);
10732
10799
 
10733
10800
  const message = JSON.parse(typeof event.data === 'string' ? event.data : '{}');
10734
10801
  let { name } = message;
@@ -10761,11 +10828,11 @@ class WebSocketClient extends Emitter {
10761
10828
  token: this.token,
10762
10829
  });
10763
10830
  this.initialized = false;
10764
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, event);
10831
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, event);
10765
10832
 
10766
10833
  switch (event.code) {
10767
10834
  case 4002:
10768
- this.eventEmitter.emit(SOCKET_EVENTS.ON_AUTH_FAILED);
10835
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_AUTH_FAILED);
10769
10836
  break;
10770
10837
  }
10771
10838
  };
@@ -10881,7 +10948,7 @@ class WebSocketClient extends Emitter {
10881
10948
  break;
10882
10949
  case 'start':
10883
10950
  this.initialized = true;
10884
- this.eventEmitter.emit(SOCKET_EVENTS.INITIALIZED);
10951
+ this.eventEmitter.emit(SOCKET_EVENTS$1.INITIALIZED);
10885
10952
  break;
10886
10953
  default:
10887
10954
  this.eventEmitter.emit('message', message);
@@ -10928,7 +10995,7 @@ class WebSocketClient extends Emitter {
10928
10995
  logger$6.log('heartbeat timed out', { host: this.host, token: this.token });
10929
10996
 
10930
10997
  this.close();
10931
- this.eventEmitter.emit(SOCKET_EVENTS.ON_CLOSE, new Error('Websocket ping failure.'));
10998
+ this.eventEmitter.emit(SOCKET_EVENTS$1.ON_CLOSE, new Error('Websocket ping failure.'));
10932
10999
 
10933
11000
  if (this.onHeartBeatTimeout) {
10934
11001
  this.onHeartBeatTimeout();
@@ -11008,7 +11075,7 @@ WebSocketClient.eventLists = [
11008
11075
 
11009
11076
  var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11010
11077
  __proto__: null,
11011
- SOCKET_EVENTS: SOCKET_EVENTS,
11078
+ SOCKET_EVENTS: SOCKET_EVENTS$1,
11012
11079
  AUTH_SESSION_EXPIRE_SOON: AUTH_SESSION_EXPIRE_SOON,
11013
11080
  FAVORITE_ADDED: FAVORITE_ADDED,
11014
11081
  FAVORITE_DELETED: FAVORITE_DELETED,
@@ -11081,10 +11148,10 @@ var WebSocketClient$1 = /*#__PURE__*/Object.freeze({
11081
11148
 
11082
11149
  //
11083
11150
 
11084
- const { SOCKET_EVENTS: SOCKET_EVENTS$1, ...OTHER_EVENTS } = WebSocketClient$1;
11085
- const ALL_EVENTS = [...Object.values(SOCKET_EVENTS$1), ...Object.values(OTHER_EVENTS)];
11151
+ const { SOCKET_EVENTS, ...OTHER_EVENTS } = WebSocketClient$1;
11152
+ const ALL_EVENTS = [...Object.values(SOCKET_EVENTS), ...Object.values(OTHER_EVENTS)];
11086
11153
 
11087
- const logger$7 = IssueReporter$1.loggerFor('simple-ws-client');
11154
+ const logger$5 = IssueReporter$1.loggerFor('simple-ws-client');
11088
11155
 
11089
11156
  class Websocket extends Emitter {
11090
11157
 
@@ -11098,9 +11165,9 @@ class Websocket extends Emitter {
11098
11165
  // $FlowFixMe
11099
11166
  this[key] = OTHER_EVENTS[key];
11100
11167
  });
11101
- Object.keys(SOCKET_EVENTS$1).forEach(key => {
11168
+ Object.keys(SOCKET_EVENTS).forEach(key => {
11102
11169
  // $FlowFixMe
11103
- this[key] = SOCKET_EVENTS$1[key];
11170
+ this[key] = SOCKET_EVENTS[key];
11104
11171
  });
11105
11172
  this.eventLists = WebSocketClient.eventLists;
11106
11173
 
@@ -11108,7 +11175,7 @@ class Websocket extends Emitter {
11108
11175
  }
11109
11176
 
11110
11177
  open(host , session ) {
11111
- logger$7.info('open simple WebSocket', { host, token: session.token });
11178
+ logger$5.info('open simple WebSocket', { host, token: session.token });
11112
11179
  this.ws = new WebSocketClient(
11113
11180
  {
11114
11181
  host,
@@ -11136,7 +11203,7 @@ class Websocket extends Emitter {
11136
11203
  }
11137
11204
 
11138
11205
  updateToken(token ) {
11139
- logger$7.info('update token via simple Websocket', { token, ws: !!this.ws });
11206
+ logger$5.info('update token via simple Websocket', { token, ws: !!this.ws });
11140
11207
 
11141
11208
  if (!this.ws) {
11142
11209
  return;
@@ -11164,7 +11231,7 @@ var Websocket$1 = global.wazoWebsocketInstance;
11164
11231
 
11165
11232
  //
11166
11233
 
11167
- const logger$8 = IssueReporter$1.loggerFor('room');
11234
+ const logger$4 = IssueReporter$1.loggerFor('room');
11168
11235
 
11169
11236
  class Participant extends Emitter {
11170
11237
 
@@ -11286,7 +11353,7 @@ class Participant extends Emitter {
11286
11353
  }
11287
11354
 
11288
11355
  onTalking(isTalking ) {
11289
- logger$8.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11356
+ logger$4.info('on participant talking', { name: this.name, isTalking, callId: this.callId });
11290
11357
  this.isTalking = isTalking;
11291
11358
  // you may notice we're not broadcasting: since all participants are getting this info
11292
11359
  // directly from asterisk, there's no need to do so
@@ -11389,7 +11456,7 @@ class Participant extends Emitter {
11389
11456
  }
11390
11457
 
11391
11458
  updateStatus(status , broadcast = true) {
11392
- logger$8.info('updating participant status', { name: this.name, status });
11459
+ logger$4.info('updating participant status', { name: this.name, status });
11393
11460
 
11394
11461
  if (typeof status.audioMuted !== 'undefined' && status.audioMuted !== this.audioMuted) {
11395
11462
  if (status.audioMuted) {
@@ -11437,7 +11504,7 @@ class Participant extends Emitter {
11437
11504
 
11438
11505
  broadcastStatus(inboundStatus = null) {
11439
11506
  const status = inboundStatus || this.getStatus();
11440
- logger$8.info('broadcasting participant status', { callId: this.callId, status });
11507
+ logger$4.info('broadcasting participant status', { callId: this.callId, status });
11441
11508
 
11442
11509
  this.room.sendSignal({
11443
11510
  type: SIGNAL_TYPE_PARTICIPANT_UPDATE,
@@ -11473,9 +11540,9 @@ class LocalParticipant extends Participant {
11473
11540
  const SIGNAL_TYPE_PARTICIPANT_UPDATE = 'signal/PARTICIPANT_UPDATE';
11474
11541
  const SIGNAL_TYPE_PARTICIPANT_REQUEST = 'signal/PARTICIPANT_REQUEST';
11475
11542
 
11476
- const logger$9 = IssueReporter$1.loggerFor('sdk-room');
11543
+ const logger$3 = IssueReporter$1.loggerFor('sdk-room');
11477
11544
 
11478
- class Room extends Emitter {
11545
+ class Room$1 extends Emitter {
11479
11546
 
11480
11547
 
11481
11548
 
@@ -11533,7 +11600,7 @@ class Room extends Emitter {
11533
11600
  extra = {},
11534
11601
  ) {
11535
11602
  super();
11536
- logger$9.info('room initialized', { callId, extension, sourceId, meetingUuid });
11603
+ logger$3.info('room initialized', { callId, extension, sourceId, meetingUuid });
11537
11604
 
11538
11605
  // Represents the room callSession
11539
11606
  this.callSession = callSession;
@@ -11599,7 +11666,7 @@ class Room extends Emitter {
11599
11666
  * @returns {Promise<Room>}
11600
11667
  */
11601
11668
  static async connect({ extension, constraints, audioOnly = false, extra, room, meeting } ) {
11602
- logger$9.info('connecting to room', { extension, audioOnly, room: !!room });
11669
+ logger$3.info('connecting to room', { extension, audioOnly, room: !!room });
11603
11670
 
11604
11671
  if (!room) {
11605
11672
  await Wazo.Phone.connect();
@@ -11612,7 +11679,7 @@ class Room extends Emitter {
11612
11679
 
11613
11680
  // Call_created is triggered before call_accepted, so we have to listen for it here.
11614
11681
  Wazo.Websocket.once(Wazo.Websocket.CALL_CREATED, ({ data }) => {
11615
- logger$9.info('room call received via WS', { callId: data.call_id });
11682
+ logger$3.info('room call received via WS', { callId: data.call_id });
11616
11683
  if (room) {
11617
11684
  room.setCallId(data.call_id);
11618
11685
  }
@@ -11620,7 +11687,7 @@ class Room extends Emitter {
11620
11687
 
11621
11688
  const callSession = await Wazo.Phone.call(extension, withCamera, null, audioOnly, true);
11622
11689
  // eslint-disable-next-line no-param-reassign
11623
- room = new Room(callSession, extension, null, null, extra);
11690
+ room = new Room$1(callSession, extension, null, null, extra);
11624
11691
 
11625
11692
  // Wait for the call to be accepted
11626
11693
  await new Promise((resolve, reject) => {
@@ -11641,7 +11708,7 @@ class Room extends Emitter {
11641
11708
  // Retrieve conference
11642
11709
  const conference = contacts.find(contact => contact.numbers.find(number => number.number === extension));
11643
11710
 
11644
- logger$9.info('connected to room', {
11711
+ logger$3.info('connected to room', {
11645
11712
  sourceId: conference ? conference.sourceId : null,
11646
11713
  name: conference ? conference.name : null,
11647
11714
  });
@@ -11651,7 +11718,7 @@ class Room extends Emitter {
11651
11718
  room.setName(conference.name);
11652
11719
  }
11653
11720
  } else if (meeting) {
11654
- logger$9.info('Already connected to meeting', {
11721
+ logger$3.info('Already connected to meeting', {
11655
11722
  uuid: meeting.uuid,
11656
11723
  name: meeting.name,
11657
11724
  });
@@ -11664,13 +11731,13 @@ class Room extends Emitter {
11664
11731
  }
11665
11732
 
11666
11733
  static disconnect() {
11667
- logger$9.info('static disconnection to room');
11734
+ logger$3.info('static disconnection to room');
11668
11735
 
11669
11736
  Wazo.Phone.disconnect();
11670
11737
  }
11671
11738
 
11672
11739
  async disconnect() {
11673
- logger$9.info('disconnection to room called');
11740
+ logger$3.info('disconnection to room called');
11674
11741
 
11675
11742
  await Wazo.Phone.hangup(this.callSession);
11676
11743
  this.callSession = null;
@@ -11690,19 +11757,19 @@ class Room extends Emitter {
11690
11757
  }
11691
11758
 
11692
11759
  setSourceId(sourceId ) {
11693
- logger$9.info('set room source id', { sourceId });
11760
+ logger$3.info('set room source id', { sourceId });
11694
11761
 
11695
11762
  this.sourceId = sourceId;
11696
11763
  }
11697
11764
 
11698
11765
  setMeetingUuid(meetingUuid ) {
11699
- logger$9.info('set meeting uuid', { meetingUuid });
11766
+ logger$3.info('set meeting uuid', { meetingUuid });
11700
11767
 
11701
11768
  this.meetingUuid = meetingUuid;
11702
11769
  }
11703
11770
 
11704
11771
  setCallId(callId ) {
11705
- logger$9.info('set room call id', { callId });
11772
+ logger$3.info('set room call id', { callId });
11706
11773
 
11707
11774
  if (callId) {
11708
11775
  this.callId = callId;
@@ -11710,7 +11777,7 @@ class Room extends Emitter {
11710
11777
  }
11711
11778
 
11712
11779
  setName(name ) {
11713
- logger$9.info('set room name', { name });
11780
+ logger$3.info('set room name', { name });
11714
11781
 
11715
11782
  this.name = name;
11716
11783
  }
@@ -11729,7 +11796,7 @@ class Room extends Emitter {
11729
11796
  }
11730
11797
 
11731
11798
  async startScreenSharing(constraints ) {
11732
- logger$9.info('start room screen sharing', { constraints });
11799
+ logger$3.info('start room screen sharing', { constraints });
11733
11800
 
11734
11801
  const screensharingStream = await Wazo.Phone.startScreenSharing(constraints, this.callSession);
11735
11802
  if (!screensharingStream) {
@@ -11743,7 +11810,7 @@ class Room extends Emitter {
11743
11810
  }
11744
11811
 
11745
11812
  async stopScreenSharing(restoreLocalStream = true) {
11746
- logger$9.info('stop room screen sharing');
11813
+ logger$3.info('stop room screen sharing');
11747
11814
 
11748
11815
  await Wazo.Phone.stopScreenSharing(this.callSession, restoreLocalStream);
11749
11816
 
@@ -11755,7 +11822,7 @@ class Room extends Emitter {
11755
11822
  }
11756
11823
 
11757
11824
  turnCameraOff() {
11758
- logger$9.info('turn room camera off');
11825
+ logger$3.info('turn room camera off');
11759
11826
 
11760
11827
  Wazo.Phone.turnCameraOff(this.callSession);
11761
11828
 
@@ -11765,7 +11832,7 @@ class Room extends Emitter {
11765
11832
  }
11766
11833
 
11767
11834
  turnCameraOn() {
11768
- logger$9.info('turn room camera on');
11835
+ logger$3.info('turn room camera on');
11769
11836
 
11770
11837
  Wazo.Phone.turnCameraOn(this.callSession);
11771
11838
 
@@ -11775,7 +11842,7 @@ class Room extends Emitter {
11775
11842
  }
11776
11843
 
11777
11844
  mute() {
11778
- logger$9.info('mute room');
11845
+ logger$3.info('mute room');
11779
11846
 
11780
11847
  Wazo.Phone.mute(this.callSession);
11781
11848
 
@@ -11783,7 +11850,7 @@ class Room extends Emitter {
11783
11850
  }
11784
11851
 
11785
11852
  unmute() {
11786
- logger$9.info('unmute room');
11853
+ logger$3.info('unmute room');
11787
11854
 
11788
11855
  Wazo.Phone.unmute(this.callSession);
11789
11856
 
@@ -11803,7 +11870,7 @@ class Room extends Emitter {
11803
11870
  }
11804
11871
 
11805
11872
  hold() {
11806
- logger$9.info('hold room');
11873
+ logger$3.info('hold room');
11807
11874
 
11808
11875
  Wazo.Phone.hold(this.callSession, true);
11809
11876
 
@@ -11813,7 +11880,7 @@ class Room extends Emitter {
11813
11880
  }
11814
11881
 
11815
11882
  async resume() {
11816
- logger$9.info('resume room');
11883
+ logger$3.info('resume room');
11817
11884
 
11818
11885
  const newStream = await Wazo.Phone.resume(this.callSession, true);
11819
11886
 
@@ -11841,13 +11908,13 @@ class Room extends Emitter {
11841
11908
  }
11842
11909
 
11843
11910
  sendDTMF(tone ) {
11844
- logger$9.info('send room DTMF', { tone });
11911
+ logger$3.info('send room DTMF', { tone });
11845
11912
 
11846
11913
  Wazo.Phone.sendDTMF(tone, this.callSession);
11847
11914
  }
11848
11915
 
11849
11916
  async sendReinvite(newConstraints = null) {
11850
- logger$9.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11917
+ logger$3.info('send room reinvite', { callId: this.callSession ? this.callSession.getId() : null, newConstraints });
11851
11918
  const wasScreensharing = this.localParticipant && this.localParticipant.screensharing;
11852
11919
 
11853
11920
  Wazo.Phone.on(Wazo.Phone.ON_SHARE_SCREEN_STARTED, () => {
@@ -11906,7 +11973,7 @@ class Room extends Emitter {
11906
11973
  Wazo.Phone.phone.on(Wazo.Phone.phone.client.ON_REINVITE, this._boundOnReinvite);
11907
11974
 
11908
11975
  this.on(this.ON_AUDIO_STREAM, stream => {
11909
- logger$9.info('on room audio stream');
11976
+ logger$3.info('on room audio stream');
11910
11977
 
11911
11978
  this.audioStream = stream;
11912
11979
  if (!this.roomAudioElement) {
@@ -11919,7 +11986,7 @@ class Room extends Emitter {
11919
11986
  });
11920
11987
 
11921
11988
  this.on(this.ON_VIDEO_STREAM, (stream, streamId, event, sipSession) => {
11922
- logger$9.info('on room video stream', { streamId });
11989
+ logger$3.info('on room video stream', { streamId });
11923
11990
 
11924
11991
  this._mapMsid(sipSession.body.body);
11925
11992
 
@@ -11934,7 +12001,7 @@ class Room extends Emitter {
11934
12001
  });
11935
12002
 
11936
12003
  this.on(this.ON_REMOVE_STREAM, stream => {
11937
- logger$9.info('on room remove stream');
12004
+ logger$3.info('on room remove stream');
11938
12005
 
11939
12006
  const participant = this.participants.find(someParticipant =>
11940
12007
  someParticipant.streams.find(someStream => someStream && someStream.id === stream.id));
@@ -12066,7 +12133,7 @@ class Room extends Emitter {
12066
12133
  const requester = this._getParticipantFromCallId(origin.callId);
12067
12134
  if (requester) {
12068
12135
  // @FIXME?: when need to trigger an update on join-in; this is a bit of a hack
12069
- logger$9.info('trigger room requester status', { origin });
12136
+ logger$3.info('trigger room requester status', { origin });
12070
12137
  requester.triggerUpdate('REQUESTER_UPDATE');
12071
12138
  }
12072
12139
  break;
@@ -12097,24 +12164,24 @@ class Room extends Emitter {
12097
12164
 
12098
12165
  // When we join the room, we can call `getConferenceParticipantsAsUser`, not before.
12099
12166
  if (participant.user_uuid === session.uuid) {
12100
- logger$9.info('room current user joined');
12167
+ logger$3.info('room current user joined');
12101
12168
 
12102
12169
  // Retrieve participants via an API calls
12103
12170
  const conferenceId = this.sourceId || payload.data.conference_id;
12104
12171
  let response;
12105
12172
  try {
12106
12173
  if (this.meetingUuid) {
12107
- logger$9.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12174
+ logger$3.info('fetching meeting participants', { meetingUuid: this.meetingUuid });
12108
12175
  response = await getApiClient().calld.getMeetingParticipantsAsUser(this.meetingUuid);
12109
12176
  } else {
12110
- logger$9.info('fetching conference participants', { conferenceId });
12177
+ logger$3.info('fetching conference participants', { conferenceId });
12111
12178
  response = await getApiClient().calld.getConferenceParticipantsAsUser(conferenceId);
12112
12179
  }
12113
12180
  } catch (e) {
12114
- logger$9.error('room participants fetching, error', e);
12181
+ logger$3.error('room participants fetching, error', e);
12115
12182
  }
12116
12183
  if (response) {
12117
- logger$9.info('conference participants fetched', { nb: response.items.length });
12184
+ logger$3.info('conference participants fetched', { nb: response.items.length });
12118
12185
  participants = response.items.map(item => {
12119
12186
  const isMe = item.call_id === this.callId;
12120
12187
 
@@ -12141,7 +12208,7 @@ class Room extends Emitter {
12141
12208
  ? new Wazo.RemoteParticipant(this, participant)
12142
12209
  : null;
12143
12210
 
12144
- logger$9.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12211
+ logger$3.info('other room user joined', { callId: participant.call_id, remoteParticipant: !!remoteParticipant });
12145
12212
 
12146
12213
  if (remoteParticipant) {
12147
12214
  this.participants.push(remoteParticipant);
@@ -12306,12 +12373,12 @@ class Room extends Emitter {
12306
12373
 
12307
12374
  //
12308
12375
 
12309
- const logger$a = IssueReporter$1.loggerFor('sdk-sip-room');
12376
+ const logger$2 = IssueReporter$1.loggerFor('sdk-sip-room');
12310
12377
 
12311
- class SipRoom extends Room {
12378
+ class SipRoom extends Room$1 {
12312
12379
 
12313
12380
  static async connect({ extension, constraints, audioOnly = false, extra, room } ) {
12314
- logger$a.info('connecting to sip room', { extension, audioOnly, room: !!room });
12381
+ logger$2.info('connecting to sip room', { extension, audioOnly, room: !!room });
12315
12382
 
12316
12383
  if (!room) {
12317
12384
  await Wazo.Phone.connect();
@@ -12327,7 +12394,7 @@ class SipRoom extends Room {
12327
12394
  room.setCallId(room.callSession.call.id);
12328
12395
  }
12329
12396
 
12330
- logger$a.info('connected to room', {
12397
+ logger$2.info('connected to room', {
12331
12398
  extension: room.extension,
12332
12399
  });
12333
12400
 
@@ -12335,7 +12402,7 @@ class SipRoom extends Room {
12335
12402
  }
12336
12403
 
12337
12404
  mute() {
12338
- logger$a.info('mute sip room');
12405
+ logger$2.info('mute sip room');
12339
12406
 
12340
12407
  Wazo.Phone.mute(this.callSession, false);
12341
12408
 
@@ -12343,7 +12410,7 @@ class SipRoom extends Room {
12343
12410
  }
12344
12411
 
12345
12412
  unmute() {
12346
- logger$a.info('unmute sip room');
12413
+ logger$2.info('unmute sip room');
12347
12414
 
12348
12415
  Wazo.Phone.unmute(this.callSession, false);
12349
12416
 
@@ -12610,7 +12677,7 @@ class NotificationOptions {
12610
12677
 
12611
12678
 
12612
12679
  // Represents a conference room, like `9000`.
12613
- class Room$1 {
12680
+ class Room {
12614
12681
 
12615
12682
 
12616
12683
 
@@ -12631,7 +12698,7 @@ class Room$1 {
12631
12698
  }
12632
12699
 
12633
12700
  connect(callSession ) {
12634
- return new Room$1({ ...this, connectedCallSession: callSession });
12701
+ return new Room({ ...this, connectedCallSession: callSession });
12635
12702
  }
12636
12703
 
12637
12704
  has(callSession ) {
@@ -12640,7 +12707,7 @@ class Room$1 {
12640
12707
 
12641
12708
  addParticipant(uuid , extension , talking = null) {
12642
12709
  if (!this.participants.some(participant => participant.uuid === uuid || participant.extension === extension)) {
12643
- return new Room$1({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12710
+ return new Room({ ...this, participants: [...this.participants, { uuid, extension, talking }] });
12644
12711
  }
12645
12712
 
12646
12713
  return this;
@@ -12659,7 +12726,7 @@ class Room$1 {
12659
12726
  updatedParticipants.push(participant);
12660
12727
  }
12661
12728
 
12662
- return new Room$1({ ...this, participants: updatedParticipants });
12729
+ return new Room({ ...this, participants: updatedParticipants });
12663
12730
  }
12664
12731
 
12665
12732
  updateParticipantByExtension(extension , participant , shouldAdd = false) {
@@ -12675,7 +12742,7 @@ class Room$1 {
12675
12742
  updatedParticipants.push(participant);
12676
12743
  }
12677
12744
 
12678
- return new Room$1({ ...this, participants: updatedParticipants });
12745
+ return new Room({ ...this, participants: updatedParticipants });
12679
12746
  }
12680
12747
 
12681
12748
  hasCallWithId(id ) {
@@ -12683,18 +12750,18 @@ class Room$1 {
12683
12750
  }
12684
12751
 
12685
12752
  disconnect() {
12686
- return new Room$1({ ...this, connectedCallSession: null });
12753
+ return new Room({ ...this, connectedCallSession: null });
12687
12754
  }
12688
12755
 
12689
12756
  removeParticipantWithUUID(uuid ) {
12690
- return new Room$1({
12757
+ return new Room({
12691
12758
  ...this,
12692
12759
  participants: this.participants.filter(participant => participant.uuid !== uuid),
12693
12760
  });
12694
12761
  }
12695
12762
 
12696
12763
  removeParticipantWithExtension(extension ) {
12697
- return new Room$1({
12764
+ return new Room({
12698
12765
  ...this,
12699
12766
  participants: this.participants.filter(participant => participant.extension !== extension),
12700
12767
  });
@@ -12705,7 +12772,7 @@ class Room$1 {
12705
12772
  }
12706
12773
 
12707
12774
  static newFrom(room ) {
12708
- return newFrom(room, Room$1);
12775
+ return newFrom(room, Room);
12709
12776
  }
12710
12777
  }
12711
12778
 
@@ -13012,11 +13079,11 @@ var wazoWebsocket = {
13012
13079
  resolve();
13013
13080
  };
13014
13081
 
13015
- client.on(SOCKET_EVENTS.ON_ERROR, error => {
13082
+ client.on(SOCKET_EVENTS$1.ON_ERROR, error => {
13016
13083
  handleError(`Connection error : ${error}`);
13017
13084
  });
13018
13085
 
13019
- client.on(SOCKET_EVENTS.ON_OPEN, () => {
13086
+ client.on(SOCKET_EVENTS$1.ON_OPEN, () => {
13020
13087
  if (session.hasEngineVersionGte(HEARTBEAT_ENGINE_VERSION)) {
13021
13088
  client.setOnHeartbeatTimeout(() => {
13022
13089
  handleError('No response to heartbeat');
@@ -13117,7 +13184,7 @@ var webrtc = {
13117
13184
  }),
13118
13185
  };
13119
13186
 
13120
- const parseCandidate$1 = line => {
13187
+ const parseCandidate = line => {
13121
13188
  let parts;
13122
13189
  // Parse both variants.
13123
13190
  if (line.indexOf('a=candidate:') === 0) {
@@ -13208,7 +13275,7 @@ var SymmetricNat = {
13208
13275
  }
13209
13276
 
13210
13277
  if (e.candidate && e.candidate.candidate.indexOf('srflx') !== -1) {
13211
- const cand = parseCandidate$1(e.candidate.candidate);
13278
+ const cand = parseCandidate(e.candidate.candidate);
13212
13279
  if (!candidates[cand.relatedPort]) candidates[cand.relatedPort] = [];
13213
13280
  candidates[cand.relatedPort].push(cand.port);
13214
13281
  } else if (!e.candidate) {
@@ -13276,7 +13343,7 @@ var iceIpv4 = {
13276
13343
  const rawCandidate = e.candidate.candidate;
13277
13344
  if (rawCandidate.indexOf('srflx') !== -1 || rawCandidate.indexOf('relay') !== -1) {
13278
13345
  hasSrflxOrRelay = true;
13279
- const candidate = parseCandidate$1(e.candidate.candidate);
13346
+ const candidate = parseCandidate(e.candidate.candidate);
13280
13347
  ips.push(candidate.ip);
13281
13348
  }
13282
13349
  } else if (!e.candidate) {
@@ -13313,7 +13380,7 @@ var checks = [
13313
13380
 
13314
13381
  //
13315
13382
 
13316
- const logger$b = IssueReporter$1.loggerFor('engine-check');
13383
+ const logger$1 = IssueReporter$1.loggerFor('engine-check');
13317
13384
 
13318
13385
  class Checker {
13319
13386
 
@@ -13331,28 +13398,28 @@ class Checker {
13331
13398
  async check(onCheckBegin = () => {}, onCheckResult = () => {}) {
13332
13399
  await this._addEngineVersion();
13333
13400
 
13334
- logger$b.info('Engine check starting');
13401
+ logger$1.info('Engine check starting');
13335
13402
 
13336
13403
  for (let i = 0; i < this.checks.length; i++) {
13337
13404
  const { name, check } = this.checks[i];
13338
13405
 
13339
- logger$b.info(`Checking ${name} ...`);
13406
+ logger$1.info(`Checking ${name} ...`);
13340
13407
 
13341
13408
  onCheckBegin(name);
13342
13409
  try {
13343
13410
  // eslint-disable-next-line no-await-in-loop
13344
13411
  const result = await check(this.server, this.session, this.externalAppConfig);
13345
- logger$b.info(`Checking ${name} success.`, { result });
13412
+ logger$1.info(`Checking ${name} success.`, { result });
13346
13413
 
13347
13414
  onCheckResult(name, result);
13348
13415
  } catch (e) {
13349
- logger$b.info(`Checking ${name} failure`, { message: e.message });
13416
+ logger$1.info(`Checking ${name} failure`, { message: e.message });
13350
13417
 
13351
13418
  onCheckResult(name, e);
13352
13419
  }
13353
13420
  }
13354
13421
 
13355
- logger$b.info('Engine check done.');
13422
+ logger$1.info('Engine check done.');
13356
13423
  }
13357
13424
 
13358
13425
  addCheck(check ) {
@@ -13376,7 +13443,7 @@ const Wazo = {
13376
13443
  Auth: Auth$1,
13377
13444
  Phone: Phone$1,
13378
13445
  Websocket: Websocket$1,
13379
- Room,
13446
+ Room: Room$1,
13380
13447
  SipRoom,
13381
13448
  RemoteParticipant,
13382
13449
  LocalParticipant,
@@ -13409,7 +13476,7 @@ const Wazo = {
13409
13476
  Session,
13410
13477
  Voicemail,
13411
13478
  Relocation,
13412
- ConferenceRoom: Room$1,
13479
+ ConferenceRoom: Room,
13413
13480
  CallSession,
13414
13481
  IndirectTransfer,
13415
13482
  SwitchboardCall,
@@ -13434,6 +13501,7 @@ const Wazo = {
13434
13501
  InvalidSubscription,
13435
13502
  InvalidAuthorization,
13436
13503
  CanceledCallError,
13504
+ SFUNotAvailableError,
13437
13505
  };
13438
13506
 
13439
13507
  if (window) {
@@ -13448,7 +13516,7 @@ if (global) {
13448
13516
  class InvalidSubscription extends Error {}
13449
13517
  class InvalidAuthorization extends Error {}
13450
13518
 
13451
- const logger$c = IssueReporter$1.loggerFor('simple-auth');
13519
+ const logger = IssueReporter$1.loggerFor('simple-auth');
13452
13520
 
13453
13521
  class Auth {
13454
13522
 
@@ -13483,7 +13551,7 @@ class Auth {
13483
13551
  setApiClientId(this.clientId);
13484
13552
  setRefreshExpiration(this.expiration);
13485
13553
  setOnRefreshToken((token , session ) => {
13486
- logger$c.info('on refresh token done', { token });
13554
+ logger.info('on refresh token done', { token });
13487
13555
  setApiToken(token);
13488
13556
  Wazo.Websocket.updateToken(token);
13489
13557
 
@@ -13528,7 +13596,7 @@ class Auth {
13528
13596
  const rawSession = await getApiClient().auth.authenticate(token);
13529
13597
  return this._onAuthenticated(rawSession);
13530
13598
  } catch (e) {
13531
- logger$c.error('on validate token error', e);
13599
+ logger.error('on validate token error', e);
13532
13600
  console.warn(e);
13533
13601
  return false;
13534
13602
  }