@wazo/sdk 0.38.3 → 0.38.6

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 (93) hide show
  1. package/README.md +10 -10
  2. package/dist/wazo-sdk.js +2 -2
  3. package/esm/__tests__/api-client.test.js +6 -0
  4. package/esm/__tests__/web-rtc-client.test.js +66 -2
  5. package/esm/api/calld.js +6 -0
  6. package/esm/api/ctid-ng.js +6 -0
  7. package/esm/api-client.js +6 -0
  8. package/esm/checker/Checker.js +16 -2
  9. package/esm/checker/checks/aor.js +6 -0
  10. package/esm/checker/checks/api.js +6 -0
  11. package/esm/checker/checks/index.js +16 -2
  12. package/esm/checker/checks/webrtc-transport.js +16 -2
  13. package/esm/checker/checks/webrtc.js +16 -2
  14. package/esm/domain/AdHocAPIConference.js +6 -0
  15. package/esm/domain/Call.js +6 -0
  16. package/esm/domain/CallSession.js +1 -1
  17. package/esm/domain/Features.js +6 -0
  18. package/esm/domain/Phone/CTIPhone.js +7 -1
  19. package/esm/domain/Phone/WebRTCPhone.js +3 -3
  20. package/esm/domain/__tests__/Call.test.js +6 -0
  21. package/esm/domain/__tests__/CallSession.test.js +1 -1
  22. package/esm/domain/__tests__/IndirectTransfer.test.js +1 -1
  23. package/esm/domain/__tests__/Line.test.js +5 -5
  24. package/esm/domain/__tests__/Room.test.js +1 -1
  25. package/esm/index.js +24 -11
  26. package/esm/lib/WazoSessionDescriptionHandler.js +8 -0
  27. package/esm/service/CallApi.js +6 -0
  28. package/esm/service/getApiClient.js +6 -0
  29. package/esm/simple/Auth.js +24 -11
  30. package/esm/simple/Configuration.js +24 -11
  31. package/esm/simple/Directory.js +6 -0
  32. package/esm/simple/Phone.js +24 -11
  33. package/esm/simple/Softphone.js +5 -6
  34. package/esm/simple/index.js +24 -11
  35. package/esm/simple/room/LocalParticipant.js +24 -11
  36. package/esm/simple/room/Participant.js +24 -11
  37. package/esm/simple/room/RemoteParticipant.js +24 -11
  38. package/esm/simple/room/Room.js +24 -11
  39. package/esm/simple/room/SipRoom.js +24 -11
  40. package/esm/simple/room/Stream.js +24 -11
  41. package/esm/simple/room/__tests__/RemoteParticipant.test.js +24 -11
  42. package/esm/simple/utils.js +24 -11
  43. package/esm/web-rtc-client.js +16 -2
  44. package/lib/__tests__/api-client.test.js +6 -0
  45. package/lib/__tests__/web-rtc-client.test.js +66 -2
  46. package/lib/api/calld.js +6 -0
  47. package/lib/api/ctid-ng.js +6 -0
  48. package/lib/api-client.js +6 -0
  49. package/lib/checker/Checker.js +16 -2
  50. package/lib/checker/checks/aor.js +6 -0
  51. package/lib/checker/checks/api.js +6 -0
  52. package/lib/checker/checks/index.js +16 -2
  53. package/lib/checker/checks/webrtc-transport.js +16 -2
  54. package/lib/checker/checks/webrtc.js +16 -2
  55. package/lib/domain/AdHocAPIConference.js +6 -0
  56. package/lib/domain/Call.js +6 -0
  57. package/lib/domain/CallSession.js +1 -1
  58. package/lib/domain/Features.js +6 -0
  59. package/lib/domain/Phone/CTIPhone.js +7 -1
  60. package/lib/domain/Phone/WebRTCPhone.js +3 -3
  61. package/lib/domain/__tests__/Call.test.js +6 -0
  62. package/lib/domain/__tests__/CallSession.test.js +1 -1
  63. package/lib/domain/__tests__/IndirectTransfer.test.js +1 -1
  64. package/lib/domain/__tests__/Line.test.js +5 -5
  65. package/lib/domain/__tests__/Room.test.js +1 -1
  66. package/lib/index.js +24 -11
  67. package/lib/lib/WazoSessionDescriptionHandler.js +8 -0
  68. package/lib/service/CallApi.js +6 -0
  69. package/lib/service/getApiClient.js +6 -0
  70. package/lib/simple/Auth.js +24 -11
  71. package/lib/simple/Configuration.js +24 -11
  72. package/lib/simple/Directory.js +6 -0
  73. package/lib/simple/Phone.js +24 -11
  74. package/lib/simple/Softphone.js +5 -6
  75. package/lib/simple/index.js +24 -11
  76. package/lib/simple/room/LocalParticipant.js +24 -11
  77. package/lib/simple/room/Participant.js +24 -11
  78. package/lib/simple/room/RemoteParticipant.js +24 -11
  79. package/lib/simple/room/Room.js +24 -11
  80. package/lib/simple/room/SipRoom.js +24 -11
  81. package/lib/simple/room/Stream.js +24 -11
  82. package/lib/simple/room/__tests__/RemoteParticipant.test.js +24 -11
  83. package/lib/simple/utils.js +24 -11
  84. package/lib/web-rtc-client.js +16 -2
  85. package/package.json +1 -1
  86. package/src/__tests__/web-rtc-client.test.js +50 -0
  87. package/src/domain/Call.js +6 -0
  88. package/src/domain/CallSession.js +1 -1
  89. package/src/domain/Phone/WebRTCPhone.js +2 -2
  90. package/src/domain/__tests__/Line.test.js +5 -5
  91. package/src/lib/WazoSessionDescriptionHandler.js +8 -0
  92. package/src/simple/Softphone.js +5 -6
  93. package/src/web-rtc-client.js +2 -2
@@ -3081,6 +3081,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3081
 
3082
3082
 
3083
3083
 
3084
+
3084
3085
 
3085
3086
 
3086
3087
 
@@ -3091,6 +3092,7 @@ const RECORD_STATE_ACTIVE = 'active';
3091
3092
 
3092
3093
 
3093
3094
 
3095
+
3094
3096
 
3095
3097
 
3096
3098
 
@@ -3119,6 +3121,7 @@ class Call {
3119
3121
 
3120
3122
 
3121
3123
 
3124
+
3122
3125
 
3123
3126
 
3124
3127
 
@@ -3143,6 +3146,7 @@ class Call {
3143
3146
  calleeNumber: plain.peer_caller_id_number,
3144
3147
  dialedExtension: plain.dialed_extension,
3145
3148
  isCaller: plain.is_caller,
3149
+ isVideo: plain.is_video,
3146
3150
  muted: plain.muted,
3147
3151
  onHold: plain.on_hold,
3148
3152
  status: plain.status,
@@ -3166,6 +3170,7 @@ class Call {
3166
3170
  calleeNumber,
3167
3171
  dialedExtension,
3168
3172
  isCaller,
3173
+ isVideo,
3169
3174
  lineId,
3170
3175
  muted,
3171
3176
  onHold,
@@ -3189,6 +3194,7 @@ class Call {
3189
3194
  this.startingTime = startingTime;
3190
3195
  this.talkingToIds = talkingToIds || [];
3191
3196
  this.recording = recording;
3197
+ this.isVideo = !!isVideo;
3192
3198
 
3193
3199
  // Useful to compare instead of instanceof with minified code
3194
3200
  this.type = 'Call';
@@ -3662,7 +3668,7 @@ class CallSession {
3662
3668
  ringing: call.isRinging(),
3663
3669
  answered: call.isUp(),
3664
3670
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3665
- cameraEnabled: false,
3671
+ cameraEnabled: call.isVideo,
3666
3672
  dialedExtension: call.dialedExtension,
3667
3673
  call,
3668
3674
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -13150,7 +13164,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13150
13164
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13151
13165
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13152
13166
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13153
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13167
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13154
13168
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13155
13169
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13156
13170
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13194,7 +13208,7 @@ class Softphone {
13194
13208
  onIFrameLoaded() {}
13195
13209
 
13196
13210
  onCallLocallyAnswered(call ) {}
13197
- onCallRemotelyAnswered(call ) {}
13211
+ onCallEstablished(call ) {}
13198
13212
  onOutgoingCallMade(call ) {}
13199
13213
  onCallIncoming(call ) {}
13200
13214
  onCallRejected(call ) {}
@@ -13254,8 +13268,7 @@ class Softphone {
13254
13268
  window.addEventListener('message', this._onMessage.bind(this), false);
13255
13269
 
13256
13270
  if (!server) {
13257
- // eslint-disable-next-line no-param-reassign
13258
- server = 'stack.dev.wazo.io';
13271
+ throw new Error('`server` is not set');
13259
13272
  }
13260
13273
 
13261
13274
  const config = { server };
@@ -13500,8 +13513,8 @@ class Softphone {
13500
13513
  case BRIDGE_ON_CALL_REJECTED:
13501
13514
  this.onCallRejected(event.data.call);
13502
13515
  break;
13503
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13504
- this.onCallRemotelyAnswered(event.data.call);
13516
+ case BRIDGE_ON_CALL_ESTABLISHED:
13517
+ this.onCallEstablished(event.data.call);
13505
13518
  break;
13506
13519
  default:
13507
13520
  this.onUnHandledEvent(event);
@@ -3083,6 +3083,7 @@ const RECORD_STATE_ACTIVE = 'active';
3083
3083
 
3084
3084
 
3085
3085
 
3086
+
3086
3087
 
3087
3088
 
3088
3089
 
@@ -3093,6 +3094,7 @@ const RECORD_STATE_ACTIVE = 'active';
3093
3094
 
3094
3095
 
3095
3096
 
3097
+
3096
3098
 
3097
3099
 
3098
3100
 
@@ -3121,6 +3123,7 @@ class Call {
3121
3123
 
3122
3124
 
3123
3125
 
3126
+
3124
3127
 
3125
3128
 
3126
3129
 
@@ -3145,6 +3148,7 @@ class Call {
3145
3148
  calleeNumber: plain.peer_caller_id_number,
3146
3149
  dialedExtension: plain.dialed_extension,
3147
3150
  isCaller: plain.is_caller,
3151
+ isVideo: plain.is_video,
3148
3152
  muted: plain.muted,
3149
3153
  onHold: plain.on_hold,
3150
3154
  status: plain.status,
@@ -3168,6 +3172,7 @@ class Call {
3168
3172
  calleeNumber,
3169
3173
  dialedExtension,
3170
3174
  isCaller,
3175
+ isVideo,
3171
3176
  lineId,
3172
3177
  muted,
3173
3178
  onHold,
@@ -3191,6 +3196,7 @@ class Call {
3191
3196
  this.startingTime = startingTime;
3192
3197
  this.talkingToIds = talkingToIds || [];
3193
3198
  this.recording = recording;
3199
+ this.isVideo = !!isVideo;
3194
3200
 
3195
3201
  // Useful to compare instead of instanceof with minified code
3196
3202
  this.type = 'Call';
@@ -3664,7 +3670,7 @@ class CallSession {
3664
3670
  ringing: call.isRinging(),
3665
3671
  answered: call.isUp(),
3666
3672
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3667
- cameraEnabled: false,
3673
+ cameraEnabled: call.isVideo,
3668
3674
  dialedExtension: call.dialedExtension,
3669
3675
  call,
3670
3676
  conference: false, // @FIXME?
@@ -6308,6 +6314,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6308
6314
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6309
6315
  if (event.candidate) {
6310
6316
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6317
+
6318
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6319
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6320
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6321
+ ice: event.candidate.candidate,
6322
+ });
6323
+ this.iceGatheringComplete();
6324
+ }
6311
6325
  }
6312
6326
  };
6313
6327
 
@@ -7791,11 +7805,11 @@ class WebRTCClient extends Emitter {
7791
7805
  });
7792
7806
  }
7793
7807
 
7794
- changeAudioInputDevice(id , session ) {
7808
+ changeAudioInputDevice(id , session , force ) {
7795
7809
  const currentId = this.getAudioDeviceId();
7796
7810
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7797
7811
 
7798
- if (id === currentId) {
7812
+ if (!force && id === currentId) {
7799
7813
  return null;
7800
7814
  }
7801
7815
 
@@ -9591,10 +9605,10 @@ class WebRTCPhone extends Emitter {
9591
9605
  this.audioRingVolume = volume;
9592
9606
  }
9593
9607
 
9594
- changeAudioInputDevice(id ) {
9608
+ changeAudioInputDevice(id , force ) {
9595
9609
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9596
9610
 
9597
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9611
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9598
9612
  }
9599
9613
 
9600
9614
  changeVideoInputDevice(id ) {
@@ -13163,7 +13177,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13163
13177
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13164
13178
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13165
13179
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13166
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13180
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13167
13181
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13168
13182
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13169
13183
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13207,7 +13221,7 @@ class Softphone {
13207
13221
  onIFrameLoaded() {}
13208
13222
 
13209
13223
  onCallLocallyAnswered(call ) {}
13210
- onCallRemotelyAnswered(call ) {}
13224
+ onCallEstablished(call ) {}
13211
13225
  onOutgoingCallMade(call ) {}
13212
13226
  onCallIncoming(call ) {}
13213
13227
  onCallRejected(call ) {}
@@ -13267,8 +13281,7 @@ class Softphone {
13267
13281
  window.addEventListener('message', this._onMessage.bind(this), false);
13268
13282
 
13269
13283
  if (!server) {
13270
- // eslint-disable-next-line no-param-reassign
13271
- server = 'stack.dev.wazo.io';
13284
+ throw new Error('`server` is not set');
13272
13285
  }
13273
13286
 
13274
13287
  const config = { server };
@@ -13513,8 +13526,8 @@ class Softphone {
13513
13526
  case BRIDGE_ON_CALL_REJECTED:
13514
13527
  this.onCallRejected(event.data.call);
13515
13528
  break;
13516
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13517
- this.onCallRemotelyAnswered(event.data.call);
13529
+ case BRIDGE_ON_CALL_ESTABLISHED:
13530
+ this.onCallEstablished(event.data.call);
13518
13531
  break;
13519
13532
  default:
13520
13533
  this.onUnHandledEvent(event);
@@ -3081,6 +3081,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3081
 
3082
3082
 
3083
3083
 
3084
+
3084
3085
 
3085
3086
 
3086
3087
 
@@ -3091,6 +3092,7 @@ const RECORD_STATE_ACTIVE = 'active';
3091
3092
 
3092
3093
 
3093
3094
 
3095
+
3094
3096
 
3095
3097
 
3096
3098
 
@@ -3119,6 +3121,7 @@ class Call {
3119
3121
 
3120
3122
 
3121
3123
 
3124
+
3122
3125
 
3123
3126
 
3124
3127
 
@@ -3143,6 +3146,7 @@ class Call {
3143
3146
  calleeNumber: plain.peer_caller_id_number,
3144
3147
  dialedExtension: plain.dialed_extension,
3145
3148
  isCaller: plain.is_caller,
3149
+ isVideo: plain.is_video,
3146
3150
  muted: plain.muted,
3147
3151
  onHold: plain.on_hold,
3148
3152
  status: plain.status,
@@ -3166,6 +3170,7 @@ class Call {
3166
3170
  calleeNumber,
3167
3171
  dialedExtension,
3168
3172
  isCaller,
3173
+ isVideo,
3169
3174
  lineId,
3170
3175
  muted,
3171
3176
  onHold,
@@ -3189,6 +3194,7 @@ class Call {
3189
3194
  this.startingTime = startingTime;
3190
3195
  this.talkingToIds = talkingToIds || [];
3191
3196
  this.recording = recording;
3197
+ this.isVideo = !!isVideo;
3192
3198
 
3193
3199
  // Useful to compare instead of instanceof with minified code
3194
3200
  this.type = 'Call';
@@ -3662,7 +3668,7 @@ class CallSession {
3662
3668
  ringing: call.isRinging(),
3663
3669
  answered: call.isUp(),
3664
3670
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3665
- cameraEnabled: false,
3671
+ cameraEnabled: call.isVideo,
3666
3672
  dialedExtension: call.dialedExtension,
3667
3673
  call,
3668
3674
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -13858,7 +13872,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13858
13872
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13859
13873
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13860
13874
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13861
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13875
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13862
13876
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13863
13877
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13864
13878
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13902,7 +13916,7 @@ class Softphone {
13902
13916
  onIFrameLoaded() {}
13903
13917
 
13904
13918
  onCallLocallyAnswered(call ) {}
13905
- onCallRemotelyAnswered(call ) {}
13919
+ onCallEstablished(call ) {}
13906
13920
  onOutgoingCallMade(call ) {}
13907
13921
  onCallIncoming(call ) {}
13908
13922
  onCallRejected(call ) {}
@@ -13962,8 +13976,7 @@ class Softphone {
13962
13976
  window.addEventListener('message', this._onMessage.bind(this), false);
13963
13977
 
13964
13978
  if (!server) {
13965
- // eslint-disable-next-line no-param-reassign
13966
- server = 'stack.dev.wazo.io';
13979
+ throw new Error('`server` is not set');
13967
13980
  }
13968
13981
 
13969
13982
  const config = { server };
@@ -14208,8 +14221,8 @@ class Softphone {
14208
14221
  case BRIDGE_ON_CALL_REJECTED:
14209
14222
  this.onCallRejected(event.data.call);
14210
14223
  break;
14211
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14212
- this.onCallRemotelyAnswered(event.data.call);
14224
+ case BRIDGE_ON_CALL_ESTABLISHED:
14225
+ this.onCallEstablished(event.data.call);
14213
14226
  break;
14214
14227
  default:
14215
14228
  this.onUnHandledEvent(event);
@@ -3081,6 +3081,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3081
 
3082
3082
 
3083
3083
 
3084
+
3084
3085
 
3085
3086
 
3086
3087
 
@@ -3091,6 +3092,7 @@ const RECORD_STATE_ACTIVE = 'active';
3091
3092
 
3092
3093
 
3093
3094
 
3095
+
3094
3096
 
3095
3097
 
3096
3098
 
@@ -3119,6 +3121,7 @@ class Call {
3119
3121
 
3120
3122
 
3121
3123
 
3124
+
3122
3125
 
3123
3126
 
3124
3127
 
@@ -3143,6 +3146,7 @@ class Call {
3143
3146
  calleeNumber: plain.peer_caller_id_number,
3144
3147
  dialedExtension: plain.dialed_extension,
3145
3148
  isCaller: plain.is_caller,
3149
+ isVideo: plain.is_video,
3146
3150
  muted: plain.muted,
3147
3151
  onHold: plain.on_hold,
3148
3152
  status: plain.status,
@@ -3166,6 +3170,7 @@ class Call {
3166
3170
  calleeNumber,
3167
3171
  dialedExtension,
3168
3172
  isCaller,
3173
+ isVideo,
3169
3174
  lineId,
3170
3175
  muted,
3171
3176
  onHold,
@@ -3189,6 +3194,7 @@ class Call {
3189
3194
  this.startingTime = startingTime;
3190
3195
  this.talkingToIds = talkingToIds || [];
3191
3196
  this.recording = recording;
3197
+ this.isVideo = !!isVideo;
3192
3198
 
3193
3199
  // Useful to compare instead of instanceof with minified code
3194
3200
  this.type = 'Call';
@@ -3662,7 +3668,7 @@ class CallSession {
3662
3668
  ringing: call.isRinging(),
3663
3669
  answered: call.isUp(),
3664
3670
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3665
- cameraEnabled: false,
3671
+ cameraEnabled: call.isVideo,
3666
3672
  dialedExtension: call.dialedExtension,
3667
3673
  call,
3668
3674
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -13939,7 +13953,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13939
13953
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13940
13954
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13941
13955
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13942
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13956
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13943
13957
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13944
13958
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13945
13959
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13983,7 +13997,7 @@ class Softphone {
13983
13997
  onIFrameLoaded() {}
13984
13998
 
13985
13999
  onCallLocallyAnswered(call ) {}
13986
- onCallRemotelyAnswered(call ) {}
14000
+ onCallEstablished(call ) {}
13987
14001
  onOutgoingCallMade(call ) {}
13988
14002
  onCallIncoming(call ) {}
13989
14003
  onCallRejected(call ) {}
@@ -14043,8 +14057,7 @@ class Softphone {
14043
14057
  window.addEventListener('message', this._onMessage.bind(this), false);
14044
14058
 
14045
14059
  if (!server) {
14046
- // eslint-disable-next-line no-param-reassign
14047
- server = 'stack.dev.wazo.io';
14060
+ throw new Error('`server` is not set');
14048
14061
  }
14049
14062
 
14050
14063
  const config = { server };
@@ -14289,8 +14302,8 @@ class Softphone {
14289
14302
  case BRIDGE_ON_CALL_REJECTED:
14290
14303
  this.onCallRejected(event.data.call);
14291
14304
  break;
14292
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14293
- this.onCallRemotelyAnswered(event.data.call);
14305
+ case BRIDGE_ON_CALL_ESTABLISHED:
14306
+ this.onCallEstablished(event.data.call);
14294
14307
  break;
14295
14308
  default:
14296
14309
  this.onUnHandledEvent(event);
@@ -3081,6 +3081,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3081
 
3082
3082
 
3083
3083
 
3084
+
3084
3085
 
3085
3086
 
3086
3087
 
@@ -3091,6 +3092,7 @@ const RECORD_STATE_ACTIVE = 'active';
3091
3092
 
3092
3093
 
3093
3094
 
3095
+
3094
3096
 
3095
3097
 
3096
3098
 
@@ -3119,6 +3121,7 @@ class Call {
3119
3121
 
3120
3122
 
3121
3123
 
3124
+
3122
3125
 
3123
3126
 
3124
3127
 
@@ -3143,6 +3146,7 @@ class Call {
3143
3146
  calleeNumber: plain.peer_caller_id_number,
3144
3147
  dialedExtension: plain.dialed_extension,
3145
3148
  isCaller: plain.is_caller,
3149
+ isVideo: plain.is_video,
3146
3150
  muted: plain.muted,
3147
3151
  onHold: plain.on_hold,
3148
3152
  status: plain.status,
@@ -3166,6 +3170,7 @@ class Call {
3166
3170
  calleeNumber,
3167
3171
  dialedExtension,
3168
3172
  isCaller,
3173
+ isVideo,
3169
3174
  lineId,
3170
3175
  muted,
3171
3176
  onHold,
@@ -3189,6 +3194,7 @@ class Call {
3189
3194
  this.startingTime = startingTime;
3190
3195
  this.talkingToIds = talkingToIds || [];
3191
3196
  this.recording = recording;
3197
+ this.isVideo = !!isVideo;
3192
3198
 
3193
3199
  // Useful to compare instead of instanceof with minified code
3194
3200
  this.type = 'Call';
@@ -3662,7 +3668,7 @@ class CallSession {
3662
3668
  ringing: call.isRinging(),
3663
3669
  answered: call.isUp(),
3664
3670
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3665
- cameraEnabled: false,
3671
+ cameraEnabled: call.isVideo,
3666
3672
  dialedExtension: call.dialedExtension,
3667
3673
  call,
3668
3674
  conference: false, // @FIXME?
@@ -6306,6 +6312,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6312
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6313
  if (event.candidate) {
6308
6314
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6315
+
6316
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6317
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6318
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6319
+ ice: event.candidate.candidate,
6320
+ });
6321
+ this.iceGatheringComplete();
6322
+ }
6309
6323
  }
6310
6324
  };
6311
6325
 
@@ -7789,11 +7803,11 @@ class WebRTCClient extends Emitter {
7789
7803
  });
7790
7804
  }
7791
7805
 
7792
- changeAudioInputDevice(id , session ) {
7806
+ changeAudioInputDevice(id , session , force ) {
7793
7807
  const currentId = this.getAudioDeviceId();
7794
7808
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7795
7809
 
7796
- if (id === currentId) {
7810
+ if (!force && id === currentId) {
7797
7811
  return null;
7798
7812
  }
7799
7813
 
@@ -9589,10 +9603,10 @@ class WebRTCPhone extends Emitter {
9589
9603
  this.audioRingVolume = volume;
9590
9604
  }
9591
9605
 
9592
- changeAudioInputDevice(id ) {
9606
+ changeAudioInputDevice(id , force ) {
9593
9607
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9594
9608
 
9595
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9609
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9596
9610
  }
9597
9611
 
9598
9612
  changeVideoInputDevice(id ) {
@@ -13997,7 +14011,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13997
14011
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13998
14012
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13999
14013
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
14000
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
14014
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
14001
14015
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14002
14016
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14003
14017
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14041,7 +14055,7 @@ class Softphone {
14041
14055
  onIFrameLoaded() {}
14042
14056
 
14043
14057
  onCallLocallyAnswered(call ) {}
14044
- onCallRemotelyAnswered(call ) {}
14058
+ onCallEstablished(call ) {}
14045
14059
  onOutgoingCallMade(call ) {}
14046
14060
  onCallIncoming(call ) {}
14047
14061
  onCallRejected(call ) {}
@@ -14101,8 +14115,7 @@ class Softphone {
14101
14115
  window.addEventListener('message', this._onMessage.bind(this), false);
14102
14116
 
14103
14117
  if (!server) {
14104
- // eslint-disable-next-line no-param-reassign
14105
- server = 'stack.dev.wazo.io';
14118
+ throw new Error('`server` is not set');
14106
14119
  }
14107
14120
 
14108
14121
  const config = { server };
@@ -14347,8 +14360,8 @@ class Softphone {
14347
14360
  case BRIDGE_ON_CALL_REJECTED:
14348
14361
  this.onCallRejected(event.data.call);
14349
14362
  break;
14350
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14351
- this.onCallRemotelyAnswered(event.data.call);
14363
+ case BRIDGE_ON_CALL_ESTABLISHED:
14364
+ this.onCallEstablished(event.data.call);
14352
14365
  break;
14353
14366
  default:
14354
14367
  this.onUnHandledEvent(event);