@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
@@ -3071,6 +3071,7 @@ const RECORD_STATE_ACTIVE = 'active';
3071
3071
 
3072
3072
 
3073
3073
 
3074
+
3074
3075
 
3075
3076
 
3076
3077
 
@@ -3081,6 +3082,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3082
 
3082
3083
 
3083
3084
 
3085
+
3084
3086
 
3085
3087
 
3086
3088
 
@@ -3109,6 +3111,7 @@ class Call {
3109
3111
 
3110
3112
 
3111
3113
 
3114
+
3112
3115
 
3113
3116
 
3114
3117
 
@@ -3133,6 +3136,7 @@ class Call {
3133
3136
  calleeNumber: plain.peer_caller_id_number,
3134
3137
  dialedExtension: plain.dialed_extension,
3135
3138
  isCaller: plain.is_caller,
3139
+ isVideo: plain.is_video,
3136
3140
  muted: plain.muted,
3137
3141
  onHold: plain.on_hold,
3138
3142
  status: plain.status,
@@ -3156,6 +3160,7 @@ class Call {
3156
3160
  calleeNumber,
3157
3161
  dialedExtension,
3158
3162
  isCaller,
3163
+ isVideo,
3159
3164
  lineId,
3160
3165
  muted,
3161
3166
  onHold,
@@ -3179,6 +3184,7 @@ class Call {
3179
3184
  this.startingTime = startingTime;
3180
3185
  this.talkingToIds = talkingToIds || [];
3181
3186
  this.recording = recording;
3187
+ this.isVideo = !!isVideo;
3182
3188
 
3183
3189
  // Useful to compare instead of instanceof with minified code
3184
3190
  this.type = 'Call';
@@ -3652,7 +3658,7 @@ class CallSession {
3652
3658
  ringing: call.isRinging(),
3653
3659
  answered: call.isUp(),
3654
3660
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3655
- cameraEnabled: false,
3661
+ cameraEnabled: call.isVideo,
3656
3662
  dialedExtension: call.dialedExtension,
3657
3663
  call,
3658
3664
  conference: false, // @FIXME?
@@ -5995,6 +6001,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
6001
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
6002
  if (event.candidate) {
5997
6003
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6004
+
6005
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6006
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6007
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6008
+ ice: event.candidate.candidate,
6009
+ });
6010
+ this.iceGatheringComplete();
6011
+ }
5998
6012
  }
5999
6013
  };
6000
6014
 
@@ -7478,11 +7492,11 @@ class WebRTCClient extends Emitter {
7478
7492
  });
7479
7493
  }
7480
7494
 
7481
- changeAudioInputDevice(id , session ) {
7495
+ changeAudioInputDevice(id , session , force ) {
7482
7496
  const currentId = this.getAudioDeviceId();
7483
7497
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7484
7498
 
7485
- if (id === currentId) {
7499
+ if (!force && id === currentId) {
7486
7500
  return null;
7487
7501
  }
7488
7502
 
@@ -9278,10 +9292,10 @@ class WebRTCPhone extends Emitter {
9278
9292
  this.audioRingVolume = volume;
9279
9293
  }
9280
9294
 
9281
- changeAudioInputDevice(id ) {
9295
+ changeAudioInputDevice(id , force ) {
9282
9296
  logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9283
9297
 
9284
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9298
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9285
9299
  }
9286
9300
 
9287
9301
  changeVideoInputDevice(id ) {
@@ -13686,7 +13700,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13686
13700
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13687
13701
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13688
13702
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13689
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13703
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13690
13704
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13691
13705
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13692
13706
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13730,7 +13744,7 @@ class Softphone {
13730
13744
  onIFrameLoaded() {}
13731
13745
 
13732
13746
  onCallLocallyAnswered(call ) {}
13733
- onCallRemotelyAnswered(call ) {}
13747
+ onCallEstablished(call ) {}
13734
13748
  onOutgoingCallMade(call ) {}
13735
13749
  onCallIncoming(call ) {}
13736
13750
  onCallRejected(call ) {}
@@ -13790,8 +13804,7 @@ class Softphone {
13790
13804
  window.addEventListener('message', this._onMessage.bind(this), false);
13791
13805
 
13792
13806
  if (!server) {
13793
- // eslint-disable-next-line no-param-reassign
13794
- server = 'stack.dev.wazo.io';
13807
+ throw new Error('`server` is not set');
13795
13808
  }
13796
13809
 
13797
13810
  const config = { server };
@@ -14036,8 +14049,8 @@ class Softphone {
14036
14049
  case BRIDGE_ON_CALL_REJECTED:
14037
14050
  this.onCallRejected(event.data.call);
14038
14051
  break;
14039
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14040
- this.onCallRemotelyAnswered(event.data.call);
14052
+ case BRIDGE_ON_CALL_ESTABLISHED:
14053
+ this.onCallEstablished(event.data.call);
14041
14054
  break;
14042
14055
  default:
14043
14056
  this.onUnHandledEvent(event);
@@ -3071,6 +3071,7 @@ const RECORD_STATE_ACTIVE = 'active';
3071
3071
 
3072
3072
 
3073
3073
 
3074
+
3074
3075
 
3075
3076
 
3076
3077
 
@@ -3081,6 +3082,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3082
 
3082
3083
 
3083
3084
 
3085
+
3084
3086
 
3085
3087
 
3086
3088
 
@@ -3109,6 +3111,7 @@ class Call {
3109
3111
 
3110
3112
 
3111
3113
 
3114
+
3112
3115
 
3113
3116
 
3114
3117
 
@@ -3133,6 +3136,7 @@ class Call {
3133
3136
  calleeNumber: plain.peer_caller_id_number,
3134
3137
  dialedExtension: plain.dialed_extension,
3135
3138
  isCaller: plain.is_caller,
3139
+ isVideo: plain.is_video,
3136
3140
  muted: plain.muted,
3137
3141
  onHold: plain.on_hold,
3138
3142
  status: plain.status,
@@ -3156,6 +3160,7 @@ class Call {
3156
3160
  calleeNumber,
3157
3161
  dialedExtension,
3158
3162
  isCaller,
3163
+ isVideo,
3159
3164
  lineId,
3160
3165
  muted,
3161
3166
  onHold,
@@ -3179,6 +3184,7 @@ class Call {
3179
3184
  this.startingTime = startingTime;
3180
3185
  this.talkingToIds = talkingToIds || [];
3181
3186
  this.recording = recording;
3187
+ this.isVideo = !!isVideo;
3182
3188
 
3183
3189
  // Useful to compare instead of instanceof with minified code
3184
3190
  this.type = 'Call';
@@ -3652,7 +3658,7 @@ class CallSession {
3652
3658
  ringing: call.isRinging(),
3653
3659
  answered: call.isUp(),
3654
3660
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3655
- cameraEnabled: false,
3661
+ cameraEnabled: call.isVideo,
3656
3662
  dialedExtension: call.dialedExtension,
3657
3663
  call,
3658
3664
  conference: false, // @FIXME?
@@ -5995,6 +6001,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
6001
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
6002
  if (event.candidate) {
5997
6003
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6004
+
6005
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6006
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6007
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6008
+ ice: event.candidate.candidate,
6009
+ });
6010
+ this.iceGatheringComplete();
6011
+ }
5998
6012
  }
5999
6013
  };
6000
6014
 
@@ -7478,11 +7492,11 @@ class WebRTCClient extends Emitter {
7478
7492
  });
7479
7493
  }
7480
7494
 
7481
- changeAudioInputDevice(id , session ) {
7495
+ changeAudioInputDevice(id , session , force ) {
7482
7496
  const currentId = this.getAudioDeviceId();
7483
7497
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7484
7498
 
7485
- if (id === currentId) {
7499
+ if (!force && id === currentId) {
7486
7500
  return null;
7487
7501
  }
7488
7502
 
@@ -9278,10 +9292,10 @@ class WebRTCPhone extends Emitter {
9278
9292
  this.audioRingVolume = volume;
9279
9293
  }
9280
9294
 
9281
- changeAudioInputDevice(id ) {
9295
+ changeAudioInputDevice(id , force ) {
9282
9296
  logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9283
9297
 
9284
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9298
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9285
9299
  }
9286
9300
 
9287
9301
  changeVideoInputDevice(id ) {
@@ -13669,7 +13683,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13669
13683
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13670
13684
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13671
13685
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13672
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13686
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13673
13687
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13674
13688
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13675
13689
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13713,7 +13727,7 @@ class Softphone {
13713
13727
  onIFrameLoaded() {}
13714
13728
 
13715
13729
  onCallLocallyAnswered(call ) {}
13716
- onCallRemotelyAnswered(call ) {}
13730
+ onCallEstablished(call ) {}
13717
13731
  onOutgoingCallMade(call ) {}
13718
13732
  onCallIncoming(call ) {}
13719
13733
  onCallRejected(call ) {}
@@ -13773,8 +13787,7 @@ class Softphone {
13773
13787
  window.addEventListener('message', this._onMessage.bind(this), false);
13774
13788
 
13775
13789
  if (!server) {
13776
- // eslint-disable-next-line no-param-reassign
13777
- server = 'stack.dev.wazo.io';
13790
+ throw new Error('`server` is not set');
13778
13791
  }
13779
13792
 
13780
13793
  const config = { server };
@@ -14019,8 +14032,8 @@ class Softphone {
14019
14032
  case BRIDGE_ON_CALL_REJECTED:
14020
14033
  this.onCallRejected(event.data.call);
14021
14034
  break;
14022
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14023
- this.onCallRemotelyAnswered(event.data.call);
14035
+ case BRIDGE_ON_CALL_ESTABLISHED:
14036
+ this.onCallEstablished(event.data.call);
14024
14037
  break;
14025
14038
  default:
14026
14039
  this.onUnHandledEvent(event);
@@ -3051,6 +3051,7 @@ const RECORD_STATE_ACTIVE = 'active';
3051
3051
 
3052
3052
 
3053
3053
 
3054
+
3054
3055
 
3055
3056
 
3056
3057
 
@@ -3061,6 +3062,7 @@ const RECORD_STATE_ACTIVE = 'active';
3061
3062
 
3062
3063
 
3063
3064
 
3065
+
3064
3066
 
3065
3067
 
3066
3068
 
@@ -3089,6 +3091,7 @@ class Call {
3089
3091
 
3090
3092
 
3091
3093
 
3094
+
3092
3095
 
3093
3096
 
3094
3097
 
@@ -3113,6 +3116,7 @@ class Call {
3113
3116
  calleeNumber: plain.peer_caller_id_number,
3114
3117
  dialedExtension: plain.dialed_extension,
3115
3118
  isCaller: plain.is_caller,
3119
+ isVideo: plain.is_video,
3116
3120
  muted: plain.muted,
3117
3121
  onHold: plain.on_hold,
3118
3122
  status: plain.status,
@@ -3136,6 +3140,7 @@ class Call {
3136
3140
  calleeNumber,
3137
3141
  dialedExtension,
3138
3142
  isCaller,
3143
+ isVideo,
3139
3144
  lineId,
3140
3145
  muted,
3141
3146
  onHold,
@@ -3159,6 +3164,7 @@ class Call {
3159
3164
  this.startingTime = startingTime;
3160
3165
  this.talkingToIds = talkingToIds || [];
3161
3166
  this.recording = recording;
3167
+ this.isVideo = !!isVideo;
3162
3168
 
3163
3169
  // Useful to compare instead of instanceof with minified code
3164
3170
  this.type = 'Call';
@@ -49,6 +49,7 @@ const RECORD_STATE_ACTIVE = 'active';
49
49
 
50
50
 
51
51
 
52
+
52
53
 
53
54
 
54
55
 
@@ -59,6 +60,7 @@ const RECORD_STATE_ACTIVE = 'active';
59
60
 
60
61
 
61
62
 
63
+
62
64
 
63
65
 
64
66
 
@@ -87,6 +89,7 @@ class Call {
87
89
 
88
90
 
89
91
 
92
+
90
93
 
91
94
 
92
95
 
@@ -111,6 +114,7 @@ class Call {
111
114
  calleeNumber: plain.peer_caller_id_number,
112
115
  dialedExtension: plain.dialed_extension,
113
116
  isCaller: plain.is_caller,
117
+ isVideo: plain.is_video,
114
118
  muted: plain.muted,
115
119
  onHold: plain.on_hold,
116
120
  status: plain.status,
@@ -134,6 +138,7 @@ class Call {
134
138
  calleeNumber,
135
139
  dialedExtension,
136
140
  isCaller,
141
+ isVideo,
137
142
  lineId,
138
143
  muted,
139
144
  onHold,
@@ -157,6 +162,7 @@ class Call {
157
162
  this.startingTime = startingTime;
158
163
  this.talkingToIds = talkingToIds || [];
159
164
  this.recording = recording;
165
+ this.isVideo = !!isVideo;
160
166
 
161
167
  // Useful to compare instead of instanceof with minified code
162
168
  this.type = 'Call';
@@ -630,7 +636,7 @@ class CallSession {
630
636
  ringing: call.isRinging(),
631
637
  answered: call.isUp(),
632
638
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
633
- cameraEnabled: false,
639
+ cameraEnabled: call.isVideo,
634
640
  dialedExtension: call.dialedExtension,
635
641
  call,
636
642
  conference: false, // @FIXME?
@@ -5995,6 +6001,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
6001
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
6002
  if (event.candidate) {
5997
6003
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6004
+
6005
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6006
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6007
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6008
+ ice: event.candidate.candidate,
6009
+ });
6010
+ this.iceGatheringComplete();
6011
+ }
5998
6012
  }
5999
6013
  };
6000
6014
 
@@ -7478,11 +7492,11 @@ class WebRTCClient extends Emitter {
7478
7492
  });
7479
7493
  }
7480
7494
 
7481
- changeAudioInputDevice(id , session ) {
7495
+ changeAudioInputDevice(id , session , force ) {
7482
7496
  const currentId = this.getAudioDeviceId();
7483
7497
  logger$9.info('setting audio input device', { id, currentId, session: !!session });
7484
7498
 
7485
- if (id === currentId) {
7499
+ if (!force && id === currentId) {
7486
7500
  return null;
7487
7501
  }
7488
7502
 
@@ -9278,10 +9292,10 @@ class WebRTCPhone extends Emitter {
9278
9292
  this.audioRingVolume = volume;
9279
9293
  }
9280
9294
 
9281
- changeAudioInputDevice(id ) {
9295
+ changeAudioInputDevice(id , force ) {
9282
9296
  logger$8.info('WebRTC phone - changeAudio input device', { deviceId: id });
9283
9297
 
9284
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9298
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9285
9299
  }
9286
9300
 
9287
9301
  changeVideoInputDevice(id ) {
@@ -13577,7 +13591,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13577
13591
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13578
13592
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13579
13593
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13580
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
13594
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13581
13595
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13582
13596
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13583
13597
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13621,7 +13635,7 @@ class Softphone {
13621
13635
  onIFrameLoaded() {}
13622
13636
 
13623
13637
  onCallLocallyAnswered(call ) {}
13624
- onCallRemotelyAnswered(call ) {}
13638
+ onCallEstablished(call ) {}
13625
13639
  onOutgoingCallMade(call ) {}
13626
13640
  onCallIncoming(call ) {}
13627
13641
  onCallRejected(call ) {}
@@ -13681,8 +13695,7 @@ class Softphone {
13681
13695
  window.addEventListener('message', this._onMessage.bind(this), false);
13682
13696
 
13683
13697
  if (!server) {
13684
- // eslint-disable-next-line no-param-reassign
13685
- server = 'stack.dev.wazo.io';
13698
+ throw new Error('`server` is not set');
13686
13699
  }
13687
13700
 
13688
13701
  const config = { server };
@@ -13927,8 +13940,8 @@ class Softphone {
13927
13940
  case BRIDGE_ON_CALL_REJECTED:
13928
13941
  this.onCallRejected(event.data.call);
13929
13942
  break;
13930
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
13931
- this.onCallRemotelyAnswered(event.data.call);
13943
+ case BRIDGE_ON_CALL_ESTABLISHED:
13944
+ this.onCallEstablished(event.data.call);
13932
13945
  break;
13933
13946
  default:
13934
13947
  this.onUnHandledEvent(event);
@@ -16,7 +16,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
16
16
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
17
17
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
18
18
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
19
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
19
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
20
20
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
21
21
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
22
22
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -60,7 +60,7 @@ class Softphone {
60
60
  onIFrameLoaded() {}
61
61
 
62
62
  onCallLocallyAnswered(call ) {}
63
- onCallRemotelyAnswered(call ) {}
63
+ onCallEstablished(call ) {}
64
64
  onOutgoingCallMade(call ) {}
65
65
  onCallIncoming(call ) {}
66
66
  onCallRejected(call ) {}
@@ -120,8 +120,7 @@ class Softphone {
120
120
  window.addEventListener('message', this._onMessage.bind(this), false);
121
121
 
122
122
  if (!server) {
123
- // eslint-disable-next-line no-param-reassign
124
- server = 'stack.dev.wazo.io';
123
+ throw new Error('`server` is not set');
125
124
  }
126
125
 
127
126
  const config = { server };
@@ -366,8 +365,8 @@ class Softphone {
366
365
  case BRIDGE_ON_CALL_REJECTED:
367
366
  this.onCallRejected(event.data.call);
368
367
  break;
369
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
370
- this.onCallRemotelyAnswered(event.data.call);
368
+ case BRIDGE_ON_CALL_ESTABLISHED:
369
+ this.onCallEstablished(event.data.call);
371
370
  break;
372
371
  default:
373
372
  this.onUnHandledEvent(event);
@@ -3071,6 +3071,7 @@ const RECORD_STATE_ACTIVE = 'active';
3071
3071
 
3072
3072
 
3073
3073
 
3074
+
3074
3075
 
3075
3076
 
3076
3077
 
@@ -3081,6 +3082,7 @@ const RECORD_STATE_ACTIVE = 'active';
3081
3082
 
3082
3083
 
3083
3084
 
3085
+
3084
3086
 
3085
3087
 
3086
3088
 
@@ -3109,6 +3111,7 @@ class Call {
3109
3111
 
3110
3112
 
3111
3113
 
3114
+
3112
3115
 
3113
3116
 
3114
3117
 
@@ -3133,6 +3136,7 @@ class Call {
3133
3136
  calleeNumber: plain.peer_caller_id_number,
3134
3137
  dialedExtension: plain.dialed_extension,
3135
3138
  isCaller: plain.is_caller,
3139
+ isVideo: plain.is_video,
3136
3140
  muted: plain.muted,
3137
3141
  onHold: plain.on_hold,
3138
3142
  status: plain.status,
@@ -3156,6 +3160,7 @@ class Call {
3156
3160
  calleeNumber,
3157
3161
  dialedExtension,
3158
3162
  isCaller,
3163
+ isVideo,
3159
3164
  lineId,
3160
3165
  muted,
3161
3166
  onHold,
@@ -3179,6 +3184,7 @@ class Call {
3179
3184
  this.startingTime = startingTime;
3180
3185
  this.talkingToIds = talkingToIds || [];
3181
3186
  this.recording = recording;
3187
+ this.isVideo = !!isVideo;
3182
3188
 
3183
3189
  // Useful to compare instead of instanceof with minified code
3184
3190
  this.type = 'Call';
@@ -3652,7 +3658,7 @@ class CallSession {
3652
3658
  ringing: call.isRinging(),
3653
3659
  answered: call.isUp(),
3654
3660
  answeredBySystem: call.isUp() && call.talkingToIds.length === 0,
3655
- cameraEnabled: false,
3661
+ cameraEnabled: call.isVideo,
3656
3662
  dialedExtension: call.dialedExtension,
3657
3663
  call,
3658
3664
  conference: false, // @FIXME?
@@ -6296,6 +6302,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6302
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6303
  if (event.candidate) {
6298
6304
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6305
+
6306
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6307
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6308
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6309
+ ice: event.candidate.candidate,
6310
+ });
6311
+ this.iceGatheringComplete();
6312
+ }
6299
6313
  }
6300
6314
  };
6301
6315
 
@@ -7779,11 +7793,11 @@ class WebRTCClient extends Emitter {
7779
7793
  });
7780
7794
  }
7781
7795
 
7782
- changeAudioInputDevice(id , session ) {
7796
+ changeAudioInputDevice(id , session , force ) {
7783
7797
  const currentId = this.getAudioDeviceId();
7784
7798
  logger$8.info('setting audio input device', { id, currentId, session: !!session });
7785
7799
 
7786
- if (id === currentId) {
7800
+ if (!force && id === currentId) {
7787
7801
  return null;
7788
7802
  }
7789
7803
 
@@ -9579,10 +9593,10 @@ class WebRTCPhone extends Emitter {
9579
9593
  this.audioRingVolume = volume;
9580
9594
  }
9581
9595
 
9582
- changeAudioInputDevice(id ) {
9596
+ changeAudioInputDevice(id , force ) {
9583
9597
  logger$7.info('WebRTC phone - changeAudio input device', { deviceId: id });
9584
9598
 
9585
- return this.client.changeAudioInputDevice(id, this.currentSipSession);
9599
+ return this.client.changeAudioInputDevice(id, this.currentSipSession, force);
9586
9600
  }
9587
9601
 
9588
9602
  changeVideoInputDevice(id ) {
@@ -13987,7 +14001,7 @@ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13987
14001
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13988
14002
  const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13989
14003
  const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13990
- const BRIDGE_ON_CALL_REMOTELY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_REMOTELY_ACCEPTED';
14004
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13991
14005
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13992
14006
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13993
14007
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14031,7 +14045,7 @@ class Softphone {
14031
14045
  onIFrameLoaded() {}
14032
14046
 
14033
14047
  onCallLocallyAnswered(call ) {}
14034
- onCallRemotelyAnswered(call ) {}
14048
+ onCallEstablished(call ) {}
14035
14049
  onOutgoingCallMade(call ) {}
14036
14050
  onCallIncoming(call ) {}
14037
14051
  onCallRejected(call ) {}
@@ -14091,8 +14105,7 @@ class Softphone {
14091
14105
  window.addEventListener('message', this._onMessage.bind(this), false);
14092
14106
 
14093
14107
  if (!server) {
14094
- // eslint-disable-next-line no-param-reassign
14095
- server = 'stack.dev.wazo.io';
14108
+ throw new Error('`server` is not set');
14096
14109
  }
14097
14110
 
14098
14111
  const config = { server };
@@ -14337,8 +14350,8 @@ class Softphone {
14337
14350
  case BRIDGE_ON_CALL_REJECTED:
14338
14351
  this.onCallRejected(event.data.call);
14339
14352
  break;
14340
- case BRIDGE_ON_CALL_REMOTELY_ACCEPTED:
14341
- this.onCallRemotelyAnswered(event.data.call);
14353
+ case BRIDGE_ON_CALL_ESTABLISHED:
14354
+ this.onCallEstablished(event.data.call);
14342
14355
  break;
14343
14356
  default:
14344
14357
  this.onUnHandledEvent(event);