@wazo/sdk 0.38.2 → 0.38.5

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 (50) hide show
  1. package/README.md +57 -10
  2. package/dist/wazo-sdk.js +5 -5
  3. package/esm/__tests__/web-rtc-client.test.js +8 -0
  4. package/esm/checker/Checker.js +8 -0
  5. package/esm/checker/checks/index.js +8 -0
  6. package/esm/checker/checks/webrtc-transport.js +8 -0
  7. package/esm/checker/checks/webrtc.js +8 -0
  8. package/esm/domain/__tests__/Line.test.js +5 -5
  9. package/esm/index.js +48 -11
  10. package/esm/lib/WazoSessionDescriptionHandler.js +8 -0
  11. package/esm/simple/Auth.js +48 -11
  12. package/esm/simple/Configuration.js +48 -11
  13. package/esm/simple/Phone.js +48 -11
  14. package/esm/simple/Softphone.js +40 -11
  15. package/esm/simple/index.js +48 -11
  16. package/esm/simple/room/LocalParticipant.js +48 -11
  17. package/esm/simple/room/Participant.js +48 -11
  18. package/esm/simple/room/RemoteParticipant.js +48 -11
  19. package/esm/simple/room/Room.js +48 -11
  20. package/esm/simple/room/SipRoom.js +48 -11
  21. package/esm/simple/room/Stream.js +48 -11
  22. package/esm/simple/room/__tests__/RemoteParticipant.test.js +48 -11
  23. package/esm/simple/utils.js +48 -11
  24. package/esm/web-rtc-client.js +8 -0
  25. package/lib/__tests__/web-rtc-client.test.js +8 -0
  26. package/lib/checker/Checker.js +8 -0
  27. package/lib/checker/checks/index.js +8 -0
  28. package/lib/checker/checks/webrtc-transport.js +8 -0
  29. package/lib/checker/checks/webrtc.js +8 -0
  30. package/lib/domain/__tests__/Line.test.js +5 -5
  31. package/lib/index.js +48 -11
  32. package/lib/lib/WazoSessionDescriptionHandler.js +8 -0
  33. package/lib/simple/Auth.js +48 -11
  34. package/lib/simple/Configuration.js +48 -11
  35. package/lib/simple/Phone.js +48 -11
  36. package/lib/simple/Softphone.js +40 -11
  37. package/lib/simple/index.js +48 -11
  38. package/lib/simple/room/LocalParticipant.js +48 -11
  39. package/lib/simple/room/Participant.js +48 -11
  40. package/lib/simple/room/RemoteParticipant.js +48 -11
  41. package/lib/simple/room/Room.js +48 -11
  42. package/lib/simple/room/SipRoom.js +48 -11
  43. package/lib/simple/room/Stream.js +48 -11
  44. package/lib/simple/room/__tests__/RemoteParticipant.test.js +48 -11
  45. package/lib/simple/utils.js +48 -11
  46. package/lib/web-rtc-client.js +8 -0
  47. package/package.json +1 -1
  48. package/src/domain/__tests__/Line.test.js +5 -5
  49. package/src/lib/WazoSessionDescriptionHandler.js +8 -0
  50. package/src/simple/Softphone.js +40 -11
@@ -876,6 +876,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
876
876
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
877
877
  if (event.candidate) {
878
878
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
879
+
880
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
881
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
882
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
883
+ ice: event.candidate.candidate,
884
+ });
885
+ this.iceGatheringComplete();
886
+ }
879
887
  }
880
888
  };
881
889
 
@@ -5606,6 +5606,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5606
5606
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5607
5607
  if (event.candidate) {
5608
5608
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5609
+
5610
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5611
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5612
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5613
+ ice: event.candidate.candidate,
5614
+ });
5615
+ this.iceGatheringComplete();
5616
+ }
5609
5617
  }
5610
5618
  };
5611
5619
 
@@ -5606,6 +5606,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5606
5606
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5607
5607
  if (event.candidate) {
5608
5608
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5609
+
5610
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5611
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5612
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5613
+ ice: event.candidate.candidate,
5614
+ });
5615
+ this.iceGatheringComplete();
5616
+ }
5609
5617
  }
5610
5618
  };
5611
5619
 
@@ -876,6 +876,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
876
876
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
877
877
  if (event.candidate) {
878
878
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
879
+
880
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
881
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
882
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
883
+ ice: event.candidate.candidate,
884
+ });
885
+ this.iceGatheringComplete();
886
+ }
879
887
  }
880
888
  };
881
889
 
@@ -876,6 +876,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
876
876
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
877
877
  if (event.candidate) {
878
878
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
879
+
880
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
881
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
882
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
883
+ ice: event.candidate.candidate,
884
+ });
885
+ this.iceGatheringComplete();
886
+ }
879
887
  }
880
888
  };
881
889
 
@@ -98,7 +98,7 @@ describe('Line domain', () => {
98
98
  username: 'ipcor1pj',
99
99
  links: [
100
100
  {
101
- href: 'https://stack.dev.wazo.io/api/confd/1.1/endpoints/sip/19',
101
+ href: 'https://stack.example.com/api/confd/1.1/endpoints/sip/19',
102
102
  rel: 'endpoint_sip',
103
103
  },
104
104
  ],
@@ -112,7 +112,7 @@ describe('Line domain', () => {
112
112
  context: 'default',
113
113
  links: [
114
114
  {
115
- href: 'https://stack.dev.wazo.io/api/confd/1.1/extensions/59',
115
+ href: 'https://stack.example.com/api/confd/1.1/extensions/59',
116
116
  rel: 'extensions',
117
117
  },
118
118
  ],
@@ -120,7 +120,7 @@ describe('Line domain', () => {
120
120
  ],
121
121
  links: [
122
122
  {
123
- href: 'https://stack.dev.wazo.io/api/confd/1.1/lines/8',
123
+ href: 'https://stack.example.com/api/confd/1.1/lines/8',
124
124
  rel: 'lines',
125
125
  },
126
126
  ],
@@ -138,7 +138,7 @@ describe('Line domain', () => {
138
138
  context: 'default',
139
139
  links: [
140
140
  {
141
- href: 'https://stack.dev.wazo.io/api/confd/1.1/extensions/59',
141
+ href: 'https://stack.example.com/api/confd/1.1/extensions/59',
142
142
  rel: 'extensions',
143
143
  },
144
144
  ],
@@ -148,7 +148,7 @@ describe('Line domain', () => {
148
148
  id: 19,
149
149
  links: [
150
150
  {
151
- href: 'https://stack.dev.wazo.io/api/confd/1.1/endpoints/sip/19',
151
+ href: 'https://stack.example.com/api/confd/1.1/endpoints/sip/19',
152
152
  rel: 'endpoint_sip',
153
153
  },
154
154
  ],
package/esm/index.js CHANGED
@@ -5817,6 +5817,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5817
5817
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5818
5818
  if (event.candidate) {
5819
5819
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5820
+
5821
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5822
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5823
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5824
+ ice: event.candidate.candidate,
5825
+ });
5826
+ this.iceGatheringComplete();
5827
+ }
5820
5828
  }
5821
5829
  };
5822
5830
 
@@ -14123,7 +14131,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
14123
14131
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
14124
14132
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
14125
14133
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
14126
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
14134
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
14135
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
14136
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
14127
14137
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14128
14138
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14129
14139
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14140,12 +14150,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14140
14150
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14141
14151
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14142
14152
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14153
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
14143
14154
 
14144
14155
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14145
14156
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14146
14157
 
14147
14158
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14148
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14159
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
14149
14160
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14150
14161
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14151
14162
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14165,10 +14176,13 @@ class Softphone {
14165
14176
  onLinkEnabled(link ) {}
14166
14177
  onIFrameLoaded() {}
14167
14178
 
14168
- onCallAnswered() {}
14169
- onCallMade(call ) {}
14179
+ onCallLocallyAnswered(call ) {}
14180
+ onCallEstablished(call ) {}
14181
+ onOutgoingCallMade(call ) {}
14170
14182
  onCallIncoming(call ) {}
14183
+ onCallRejected(call ) {}
14171
14184
  onCallEnded(call , card , direction , fromExtension ) {}
14185
+
14172
14186
  onCardSaved(card ) {}
14173
14187
  onCardCanceled() {}
14174
14188
  onAuthenticated(session ) {}
@@ -14200,7 +14214,18 @@ class Softphone {
14200
14214
  onStopRecording() {}
14201
14215
  onUnHandledEvent(event ) {}
14202
14216
 
14203
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14217
+ init({
14218
+ url,
14219
+ width,
14220
+ height,
14221
+ server,
14222
+ port,
14223
+ language,
14224
+ wrapUpDuration,
14225
+ enableAgent = true,
14226
+ tenantId,
14227
+ debug = false,
14228
+ } = {}) {
14204
14229
  this.url = url || 'https://softphone.wazo.io';
14205
14230
  this.width = width || 500;
14206
14231
  this.height = height || 600;
@@ -14212,8 +14237,7 @@ class Softphone {
14212
14237
  window.addEventListener('message', this._onMessage.bind(this), false);
14213
14238
 
14214
14239
  if (!server) {
14215
- // eslint-disable-next-line no-param-reassign
14216
- server = 'stack.dev.wazo.io';
14240
+ throw new Error('`server` is not set');
14217
14241
  }
14218
14242
 
14219
14243
  const config = { server };
@@ -14223,6 +14247,9 @@ class Softphone {
14223
14247
  if (port) {
14224
14248
  config.port = port;
14225
14249
  }
14250
+ if (tenantId) {
14251
+ config.tenantId = tenantId;
14252
+ }
14226
14253
  if (wrapUpDuration) {
14227
14254
  config.wrapUpDuration = wrapUpDuration;
14228
14255
  }
@@ -14233,6 +14260,10 @@ class Softphone {
14233
14260
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14234
14261
  }
14235
14262
 
14263
+ if (debug) {
14264
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14265
+ }
14266
+
14236
14267
  this._createIframe(() => {
14237
14268
  this.iframeLoaded = true;
14238
14269
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14353,8 +14384,8 @@ class Softphone {
14353
14384
  }
14354
14385
 
14355
14386
  switch (event.data.type) {
14356
- case SDK_ON_CALL_MADE:
14357
- this.onCallMade(event.data.callSession);
14387
+ case SDK_ON_OUTGOING_CALL_MADE:
14388
+ this.onOutgoingCallMade(event.data.callSession);
14358
14389
  break;
14359
14390
  case SDK_CALL_ENDED: {
14360
14391
  const { callSession, content, direction, userExtension } = event.data;
@@ -14445,8 +14476,14 @@ class Softphone {
14445
14476
  case BRIDGE_ON_CARD_CANCELED:
14446
14477
  this.onCardCanceled();
14447
14478
  break;
14448
- case BRIDGE_ON_CALL_ANSWERED:
14449
- this.onCallAnswered();
14479
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14480
+ this.onCallLocallyAnswered(event.data.call);
14481
+ break;
14482
+ case BRIDGE_ON_CALL_REJECTED:
14483
+ this.onCallRejected(event.data.call);
14484
+ break;
14485
+ case BRIDGE_ON_CALL_ESTABLISHED:
14486
+ this.onCallEstablished(event.data.call);
14450
14487
  break;
14451
14488
  default:
14452
14489
  this.onUnHandledEvent(event);
@@ -540,6 +540,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
540
540
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
541
541
  if (event.candidate) {
542
542
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
543
+
544
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
545
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
546
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
547
+ ice: event.candidate.candidate,
548
+ });
549
+ this.iceGatheringComplete();
550
+ }
543
551
  }
544
552
  };
545
553
 
@@ -5995,6 +5995,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
5995
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
5996
  if (event.candidate) {
5997
5997
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5998
+
5999
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6000
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6001
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6002
+ ice: event.candidate.candidate,
6003
+ });
6004
+ this.iceGatheringComplete();
6005
+ }
5998
6006
  }
5999
6007
  };
6000
6008
 
@@ -13684,7 +13692,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13684
13692
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13685
13693
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13686
13694
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13687
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13695
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13696
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13697
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13688
13698
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13689
13699
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13690
13700
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13701,12 +13711,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13701
13711
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13702
13712
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13703
13713
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13714
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13704
13715
 
13705
13716
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13706
13717
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13707
13718
 
13708
13719
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13709
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13720
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13710
13721
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13711
13722
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13712
13723
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13726,10 +13737,13 @@ class Softphone {
13726
13737
  onLinkEnabled(link ) {}
13727
13738
  onIFrameLoaded() {}
13728
13739
 
13729
- onCallAnswered() {}
13730
- onCallMade(call ) {}
13740
+ onCallLocallyAnswered(call ) {}
13741
+ onCallEstablished(call ) {}
13742
+ onOutgoingCallMade(call ) {}
13731
13743
  onCallIncoming(call ) {}
13744
+ onCallRejected(call ) {}
13732
13745
  onCallEnded(call , card , direction , fromExtension ) {}
13746
+
13733
13747
  onCardSaved(card ) {}
13734
13748
  onCardCanceled() {}
13735
13749
  onAuthenticated(session ) {}
@@ -13761,7 +13775,18 @@ class Softphone {
13761
13775
  onStopRecording() {}
13762
13776
  onUnHandledEvent(event ) {}
13763
13777
 
13764
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13778
+ init({
13779
+ url,
13780
+ width,
13781
+ height,
13782
+ server,
13783
+ port,
13784
+ language,
13785
+ wrapUpDuration,
13786
+ enableAgent = true,
13787
+ tenantId,
13788
+ debug = false,
13789
+ } = {}) {
13765
13790
  this.url = url || 'https://softphone.wazo.io';
13766
13791
  this.width = width || 500;
13767
13792
  this.height = height || 600;
@@ -13773,8 +13798,7 @@ class Softphone {
13773
13798
  window.addEventListener('message', this._onMessage.bind(this), false);
13774
13799
 
13775
13800
  if (!server) {
13776
- // eslint-disable-next-line no-param-reassign
13777
- server = 'stack.dev.wazo.io';
13801
+ throw new Error('`server` is not set');
13778
13802
  }
13779
13803
 
13780
13804
  const config = { server };
@@ -13784,6 +13808,9 @@ class Softphone {
13784
13808
  if (port) {
13785
13809
  config.port = port;
13786
13810
  }
13811
+ if (tenantId) {
13812
+ config.tenantId = tenantId;
13813
+ }
13787
13814
  if (wrapUpDuration) {
13788
13815
  config.wrapUpDuration = wrapUpDuration;
13789
13816
  }
@@ -13794,6 +13821,10 @@ class Softphone {
13794
13821
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13795
13822
  }
13796
13823
 
13824
+ if (debug) {
13825
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13826
+ }
13827
+
13797
13828
  this._createIframe(() => {
13798
13829
  this.iframeLoaded = true;
13799
13830
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13914,8 +13945,8 @@ class Softphone {
13914
13945
  }
13915
13946
 
13916
13947
  switch (event.data.type) {
13917
- case SDK_ON_CALL_MADE:
13918
- this.onCallMade(event.data.callSession);
13948
+ case SDK_ON_OUTGOING_CALL_MADE:
13949
+ this.onOutgoingCallMade(event.data.callSession);
13919
13950
  break;
13920
13951
  case SDK_CALL_ENDED: {
13921
13952
  const { callSession, content, direction, userExtension } = event.data;
@@ -14006,8 +14037,14 @@ class Softphone {
14006
14037
  case BRIDGE_ON_CARD_CANCELED:
14007
14038
  this.onCardCanceled();
14008
14039
  break;
14009
- case BRIDGE_ON_CALL_ANSWERED:
14010
- this.onCallAnswered();
14040
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14041
+ this.onCallLocallyAnswered(event.data.call);
14042
+ break;
14043
+ case BRIDGE_ON_CALL_REJECTED:
14044
+ this.onCallRejected(event.data.call);
14045
+ break;
14046
+ case BRIDGE_ON_CALL_ESTABLISHED:
14047
+ this.onCallEstablished(event.data.call);
14011
14048
  break;
14012
14049
  default:
14013
14050
  this.onUnHandledEvent(event);
@@ -5995,6 +5995,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
5995
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
5996
  if (event.candidate) {
5997
5997
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5998
+
5999
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6000
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6001
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6002
+ ice: event.candidate.candidate,
6003
+ });
6004
+ this.iceGatheringComplete();
6005
+ }
5998
6006
  }
5999
6007
  };
6000
6008
 
@@ -13667,7 +13675,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13667
13675
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13668
13676
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13669
13677
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13670
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13678
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13679
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13680
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13671
13681
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13672
13682
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13673
13683
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13684,12 +13694,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13684
13694
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13685
13695
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13686
13696
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13697
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13687
13698
 
13688
13699
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13689
13700
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13690
13701
 
13691
13702
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13692
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13703
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13693
13704
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13694
13705
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13695
13706
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13709,10 +13720,13 @@ class Softphone {
13709
13720
  onLinkEnabled(link ) {}
13710
13721
  onIFrameLoaded() {}
13711
13722
 
13712
- onCallAnswered() {}
13713
- onCallMade(call ) {}
13723
+ onCallLocallyAnswered(call ) {}
13724
+ onCallEstablished(call ) {}
13725
+ onOutgoingCallMade(call ) {}
13714
13726
  onCallIncoming(call ) {}
13727
+ onCallRejected(call ) {}
13715
13728
  onCallEnded(call , card , direction , fromExtension ) {}
13729
+
13716
13730
  onCardSaved(card ) {}
13717
13731
  onCardCanceled() {}
13718
13732
  onAuthenticated(session ) {}
@@ -13744,7 +13758,18 @@ class Softphone {
13744
13758
  onStopRecording() {}
13745
13759
  onUnHandledEvent(event ) {}
13746
13760
 
13747
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13761
+ init({
13762
+ url,
13763
+ width,
13764
+ height,
13765
+ server,
13766
+ port,
13767
+ language,
13768
+ wrapUpDuration,
13769
+ enableAgent = true,
13770
+ tenantId,
13771
+ debug = false,
13772
+ } = {}) {
13748
13773
  this.url = url || 'https://softphone.wazo.io';
13749
13774
  this.width = width || 500;
13750
13775
  this.height = height || 600;
@@ -13756,8 +13781,7 @@ class Softphone {
13756
13781
  window.addEventListener('message', this._onMessage.bind(this), false);
13757
13782
 
13758
13783
  if (!server) {
13759
- // eslint-disable-next-line no-param-reassign
13760
- server = 'stack.dev.wazo.io';
13784
+ throw new Error('`server` is not set');
13761
13785
  }
13762
13786
 
13763
13787
  const config = { server };
@@ -13767,6 +13791,9 @@ class Softphone {
13767
13791
  if (port) {
13768
13792
  config.port = port;
13769
13793
  }
13794
+ if (tenantId) {
13795
+ config.tenantId = tenantId;
13796
+ }
13770
13797
  if (wrapUpDuration) {
13771
13798
  config.wrapUpDuration = wrapUpDuration;
13772
13799
  }
@@ -13777,6 +13804,10 @@ class Softphone {
13777
13804
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13778
13805
  }
13779
13806
 
13807
+ if (debug) {
13808
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13809
+ }
13810
+
13780
13811
  this._createIframe(() => {
13781
13812
  this.iframeLoaded = true;
13782
13813
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13897,8 +13928,8 @@ class Softphone {
13897
13928
  }
13898
13929
 
13899
13930
  switch (event.data.type) {
13900
- case SDK_ON_CALL_MADE:
13901
- this.onCallMade(event.data.callSession);
13931
+ case SDK_ON_OUTGOING_CALL_MADE:
13932
+ this.onOutgoingCallMade(event.data.callSession);
13902
13933
  break;
13903
13934
  case SDK_CALL_ENDED: {
13904
13935
  const { callSession, content, direction, userExtension } = event.data;
@@ -13989,8 +14020,14 @@ class Softphone {
13989
14020
  case BRIDGE_ON_CARD_CANCELED:
13990
14021
  this.onCardCanceled();
13991
14022
  break;
13992
- case BRIDGE_ON_CALL_ANSWERED:
13993
- this.onCallAnswered();
14023
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14024
+ this.onCallLocallyAnswered(event.data.call);
14025
+ break;
14026
+ case BRIDGE_ON_CALL_REJECTED:
14027
+ this.onCallRejected(event.data.call);
14028
+ break;
14029
+ case BRIDGE_ON_CALL_ESTABLISHED:
14030
+ this.onCallEstablished(event.data.call);
13994
14031
  break;
13995
14032
  default:
13996
14033
  this.onUnHandledEvent(event);
@@ -5995,6 +5995,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
5995
5995
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5996
5996
  if (event.candidate) {
5997
5997
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5998
+
5999
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6000
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6001
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6002
+ ice: event.candidate.candidate,
6003
+ });
6004
+ this.iceGatheringComplete();
6005
+ }
5998
6006
  }
5999
6007
  };
6000
6008
 
@@ -13575,7 +13583,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13575
13583
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13576
13584
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13577
13585
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13578
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13586
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13587
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13588
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13579
13589
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13580
13590
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13581
13591
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13592,12 +13602,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13592
13602
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13593
13603
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13594
13604
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13605
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13595
13606
 
13596
13607
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13597
13608
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13598
13609
 
13599
13610
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13600
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13611
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13601
13612
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13602
13613
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13603
13614
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13617,10 +13628,13 @@ class Softphone {
13617
13628
  onLinkEnabled(link ) {}
13618
13629
  onIFrameLoaded() {}
13619
13630
 
13620
- onCallAnswered() {}
13621
- onCallMade(call ) {}
13631
+ onCallLocallyAnswered(call ) {}
13632
+ onCallEstablished(call ) {}
13633
+ onOutgoingCallMade(call ) {}
13622
13634
  onCallIncoming(call ) {}
13635
+ onCallRejected(call ) {}
13623
13636
  onCallEnded(call , card , direction , fromExtension ) {}
13637
+
13624
13638
  onCardSaved(card ) {}
13625
13639
  onCardCanceled() {}
13626
13640
  onAuthenticated(session ) {}
@@ -13652,7 +13666,18 @@ class Softphone {
13652
13666
  onStopRecording() {}
13653
13667
  onUnHandledEvent(event ) {}
13654
13668
 
13655
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13669
+ init({
13670
+ url,
13671
+ width,
13672
+ height,
13673
+ server,
13674
+ port,
13675
+ language,
13676
+ wrapUpDuration,
13677
+ enableAgent = true,
13678
+ tenantId,
13679
+ debug = false,
13680
+ } = {}) {
13656
13681
  this.url = url || 'https://softphone.wazo.io';
13657
13682
  this.width = width || 500;
13658
13683
  this.height = height || 600;
@@ -13664,8 +13689,7 @@ class Softphone {
13664
13689
  window.addEventListener('message', this._onMessage.bind(this), false);
13665
13690
 
13666
13691
  if (!server) {
13667
- // eslint-disable-next-line no-param-reassign
13668
- server = 'stack.dev.wazo.io';
13692
+ throw new Error('`server` is not set');
13669
13693
  }
13670
13694
 
13671
13695
  const config = { server };
@@ -13675,6 +13699,9 @@ class Softphone {
13675
13699
  if (port) {
13676
13700
  config.port = port;
13677
13701
  }
13702
+ if (tenantId) {
13703
+ config.tenantId = tenantId;
13704
+ }
13678
13705
  if (wrapUpDuration) {
13679
13706
  config.wrapUpDuration = wrapUpDuration;
13680
13707
  }
@@ -13685,6 +13712,10 @@ class Softphone {
13685
13712
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13686
13713
  }
13687
13714
 
13715
+ if (debug) {
13716
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13717
+ }
13718
+
13688
13719
  this._createIframe(() => {
13689
13720
  this.iframeLoaded = true;
13690
13721
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13805,8 +13836,8 @@ class Softphone {
13805
13836
  }
13806
13837
 
13807
13838
  switch (event.data.type) {
13808
- case SDK_ON_CALL_MADE:
13809
- this.onCallMade(event.data.callSession);
13839
+ case SDK_ON_OUTGOING_CALL_MADE:
13840
+ this.onOutgoingCallMade(event.data.callSession);
13810
13841
  break;
13811
13842
  case SDK_CALL_ENDED: {
13812
13843
  const { callSession, content, direction, userExtension } = event.data;
@@ -13897,8 +13928,14 @@ class Softphone {
13897
13928
  case BRIDGE_ON_CARD_CANCELED:
13898
13929
  this.onCardCanceled();
13899
13930
  break;
13900
- case BRIDGE_ON_CALL_ANSWERED:
13901
- this.onCallAnswered();
13931
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
13932
+ this.onCallLocallyAnswered(event.data.call);
13933
+ break;
13934
+ case BRIDGE_ON_CALL_REJECTED:
13935
+ this.onCallRejected(event.data.call);
13936
+ break;
13937
+ case BRIDGE_ON_CALL_ESTABLISHED:
13938
+ this.onCallEstablished(event.data.call);
13902
13939
  break;
13903
13940
  default:
13904
13941
  this.onUnHandledEvent(event);