@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
@@ -885,6 +885,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
885
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
886
  if (event.candidate) {
887
887
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
888
+
889
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
890
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
891
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
892
+ ice: event.candidate.candidate,
893
+ });
894
+ this.iceGatheringComplete();
895
+ }
888
896
  }
889
897
  };
890
898
 
@@ -5616,6 +5616,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5616
5616
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5617
5617
  if (event.candidate) {
5618
5618
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5619
+
5620
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5621
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5622
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5623
+ ice: event.candidate.candidate,
5624
+ });
5625
+ this.iceGatheringComplete();
5626
+ }
5619
5627
  }
5620
5628
  };
5621
5629
 
@@ -5616,6 +5616,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5616
5616
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5617
5617
  if (event.candidate) {
5618
5618
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5619
+
5620
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5621
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5622
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5623
+ ice: event.candidate.candidate,
5624
+ });
5625
+ this.iceGatheringComplete();
5626
+ }
5619
5627
  }
5620
5628
  };
5621
5629
 
@@ -885,6 +885,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
885
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
886
  if (event.candidate) {
887
887
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
888
+
889
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
890
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
891
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
892
+ ice: event.candidate.candidate,
893
+ });
894
+ this.iceGatheringComplete();
895
+ }
888
896
  }
889
897
  };
890
898
 
@@ -885,6 +885,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
885
885
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
886
886
  if (event.candidate) {
887
887
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
888
+
889
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
890
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
891
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
892
+ ice: event.candidate.candidate,
893
+ });
894
+ this.iceGatheringComplete();
895
+ }
888
896
  }
889
897
  };
890
898
 
@@ -100,7 +100,7 @@ describe('Line domain', () => {
100
100
  username: 'ipcor1pj',
101
101
  links: [
102
102
  {
103
- href: 'https://stack.dev.wazo.io/api/confd/1.1/endpoints/sip/19',
103
+ href: 'https://stack.example.com/api/confd/1.1/endpoints/sip/19',
104
104
  rel: 'endpoint_sip',
105
105
  },
106
106
  ],
@@ -114,7 +114,7 @@ describe('Line domain', () => {
114
114
  context: 'default',
115
115
  links: [
116
116
  {
117
- href: 'https://stack.dev.wazo.io/api/confd/1.1/extensions/59',
117
+ href: 'https://stack.example.com/api/confd/1.1/extensions/59',
118
118
  rel: 'extensions',
119
119
  },
120
120
  ],
@@ -122,7 +122,7 @@ describe('Line domain', () => {
122
122
  ],
123
123
  links: [
124
124
  {
125
- href: 'https://stack.dev.wazo.io/api/confd/1.1/lines/8',
125
+ href: 'https://stack.example.com/api/confd/1.1/lines/8',
126
126
  rel: 'lines',
127
127
  },
128
128
  ],
@@ -140,7 +140,7 @@ describe('Line domain', () => {
140
140
  context: 'default',
141
141
  links: [
142
142
  {
143
- href: 'https://stack.dev.wazo.io/api/confd/1.1/extensions/59',
143
+ href: 'https://stack.example.com/api/confd/1.1/extensions/59',
144
144
  rel: 'extensions',
145
145
  },
146
146
  ],
@@ -150,7 +150,7 @@ describe('Line domain', () => {
150
150
  id: 19,
151
151
  links: [
152
152
  {
153
- href: 'https://stack.dev.wazo.io/api/confd/1.1/endpoints/sip/19',
153
+ href: 'https://stack.example.com/api/confd/1.1/endpoints/sip/19',
154
154
  rel: 'endpoint_sip',
155
155
  },
156
156
  ],
package/lib/index.js CHANGED
@@ -5828,6 +5828,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
5828
5828
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
5829
5829
  if (event.candidate) {
5830
5830
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
5831
+
5832
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
5833
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
5834
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
5835
+ ice: event.candidate.candidate,
5836
+ });
5837
+ this.iceGatheringComplete();
5838
+ }
5831
5839
  }
5832
5840
  };
5833
5841
 
@@ -14134,7 +14142,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
14134
14142
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
14135
14143
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
14136
14144
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
14137
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
14145
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
14146
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
14147
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
14138
14148
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14139
14149
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14140
14150
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14151,12 +14161,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14151
14161
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14152
14162
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14153
14163
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14164
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
14154
14165
 
14155
14166
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14156
14167
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14157
14168
 
14158
14169
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14159
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14170
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
14160
14171
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14161
14172
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14162
14173
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14176,10 +14187,13 @@ class Softphone {
14176
14187
  onLinkEnabled(link ) {}
14177
14188
  onIFrameLoaded() {}
14178
14189
 
14179
- onCallAnswered() {}
14180
- onCallMade(call ) {}
14190
+ onCallLocallyAnswered(call ) {}
14191
+ onCallEstablished(call ) {}
14192
+ onOutgoingCallMade(call ) {}
14181
14193
  onCallIncoming(call ) {}
14194
+ onCallRejected(call ) {}
14182
14195
  onCallEnded(call , card , direction , fromExtension ) {}
14196
+
14183
14197
  onCardSaved(card ) {}
14184
14198
  onCardCanceled() {}
14185
14199
  onAuthenticated(session ) {}
@@ -14211,7 +14225,18 @@ class Softphone {
14211
14225
  onStopRecording() {}
14212
14226
  onUnHandledEvent(event ) {}
14213
14227
 
14214
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14228
+ init({
14229
+ url,
14230
+ width,
14231
+ height,
14232
+ server,
14233
+ port,
14234
+ language,
14235
+ wrapUpDuration,
14236
+ enableAgent = true,
14237
+ tenantId,
14238
+ debug = false,
14239
+ } = {}) {
14215
14240
  this.url = url || 'https://softphone.wazo.io';
14216
14241
  this.width = width || 500;
14217
14242
  this.height = height || 600;
@@ -14223,8 +14248,7 @@ class Softphone {
14223
14248
  window.addEventListener('message', this._onMessage.bind(this), false);
14224
14249
 
14225
14250
  if (!server) {
14226
- // eslint-disable-next-line no-param-reassign
14227
- server = 'stack.dev.wazo.io';
14251
+ throw new Error('`server` is not set');
14228
14252
  }
14229
14253
 
14230
14254
  const config = { server };
@@ -14234,6 +14258,9 @@ class Softphone {
14234
14258
  if (port) {
14235
14259
  config.port = port;
14236
14260
  }
14261
+ if (tenantId) {
14262
+ config.tenantId = tenantId;
14263
+ }
14237
14264
  if (wrapUpDuration) {
14238
14265
  config.wrapUpDuration = wrapUpDuration;
14239
14266
  }
@@ -14244,6 +14271,10 @@ class Softphone {
14244
14271
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14245
14272
  }
14246
14273
 
14274
+ if (debug) {
14275
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14276
+ }
14277
+
14247
14278
  this._createIframe(() => {
14248
14279
  this.iframeLoaded = true;
14249
14280
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14364,8 +14395,8 @@ class Softphone {
14364
14395
  }
14365
14396
 
14366
14397
  switch (event.data.type) {
14367
- case SDK_ON_CALL_MADE:
14368
- this.onCallMade(event.data.callSession);
14398
+ case SDK_ON_OUTGOING_CALL_MADE:
14399
+ this.onOutgoingCallMade(event.data.callSession);
14369
14400
  break;
14370
14401
  case SDK_CALL_ENDED: {
14371
14402
  const { callSession, content, direction, userExtension } = event.data;
@@ -14456,8 +14487,14 @@ class Softphone {
14456
14487
  case BRIDGE_ON_CARD_CANCELED:
14457
14488
  this.onCardCanceled();
14458
14489
  break;
14459
- case BRIDGE_ON_CALL_ANSWERED:
14460
- this.onCallAnswered();
14490
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14491
+ this.onCallLocallyAnswered(event.data.call);
14492
+ break;
14493
+ case BRIDGE_ON_CALL_REJECTED:
14494
+ this.onCallRejected(event.data.call);
14495
+ break;
14496
+ case BRIDGE_ON_CALL_ESTABLISHED:
14497
+ this.onCallEstablished(event.data.call);
14461
14498
  break;
14462
14499
  default:
14463
14500
  this.onUnHandledEvent(event);
@@ -550,6 +550,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
550
550
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
551
551
  if (event.candidate) {
552
552
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
553
+
554
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
555
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
556
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
557
+ ice: event.candidate.candidate,
558
+ });
559
+ this.iceGatheringComplete();
560
+ }
553
561
  }
554
562
  };
555
563
 
@@ -6007,6 +6007,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6007
6007
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6008
6008
  if (event.candidate) {
6009
6009
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6010
+
6011
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6012
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6013
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6014
+ ice: event.candidate.candidate,
6015
+ });
6016
+ this.iceGatheringComplete();
6017
+ }
6010
6018
  }
6011
6019
  };
6012
6020
 
@@ -13696,7 +13704,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13696
13704
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13697
13705
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13698
13706
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13699
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13707
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13708
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13709
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13700
13710
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13701
13711
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13702
13712
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13713,12 +13723,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13713
13723
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13714
13724
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13715
13725
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13726
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13716
13727
 
13717
13728
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13718
13729
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13719
13730
 
13720
13731
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13721
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13732
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13722
13733
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13723
13734
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13724
13735
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13738,10 +13749,13 @@ class Softphone {
13738
13749
  onLinkEnabled(link ) {}
13739
13750
  onIFrameLoaded() {}
13740
13751
 
13741
- onCallAnswered() {}
13742
- onCallMade(call ) {}
13752
+ onCallLocallyAnswered(call ) {}
13753
+ onCallEstablished(call ) {}
13754
+ onOutgoingCallMade(call ) {}
13743
13755
  onCallIncoming(call ) {}
13756
+ onCallRejected(call ) {}
13744
13757
  onCallEnded(call , card , direction , fromExtension ) {}
13758
+
13745
13759
  onCardSaved(card ) {}
13746
13760
  onCardCanceled() {}
13747
13761
  onAuthenticated(session ) {}
@@ -13773,7 +13787,18 @@ class Softphone {
13773
13787
  onStopRecording() {}
13774
13788
  onUnHandledEvent(event ) {}
13775
13789
 
13776
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13790
+ init({
13791
+ url,
13792
+ width,
13793
+ height,
13794
+ server,
13795
+ port,
13796
+ language,
13797
+ wrapUpDuration,
13798
+ enableAgent = true,
13799
+ tenantId,
13800
+ debug = false,
13801
+ } = {}) {
13777
13802
  this.url = url || 'https://softphone.wazo.io';
13778
13803
  this.width = width || 500;
13779
13804
  this.height = height || 600;
@@ -13785,8 +13810,7 @@ class Softphone {
13785
13810
  window.addEventListener('message', this._onMessage.bind(this), false);
13786
13811
 
13787
13812
  if (!server) {
13788
- // eslint-disable-next-line no-param-reassign
13789
- server = 'stack.dev.wazo.io';
13813
+ throw new Error('`server` is not set');
13790
13814
  }
13791
13815
 
13792
13816
  const config = { server };
@@ -13796,6 +13820,9 @@ class Softphone {
13796
13820
  if (port) {
13797
13821
  config.port = port;
13798
13822
  }
13823
+ if (tenantId) {
13824
+ config.tenantId = tenantId;
13825
+ }
13799
13826
  if (wrapUpDuration) {
13800
13827
  config.wrapUpDuration = wrapUpDuration;
13801
13828
  }
@@ -13806,6 +13833,10 @@ class Softphone {
13806
13833
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13807
13834
  }
13808
13835
 
13836
+ if (debug) {
13837
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13838
+ }
13839
+
13809
13840
  this._createIframe(() => {
13810
13841
  this.iframeLoaded = true;
13811
13842
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13926,8 +13957,8 @@ class Softphone {
13926
13957
  }
13927
13958
 
13928
13959
  switch (event.data.type) {
13929
- case SDK_ON_CALL_MADE:
13930
- this.onCallMade(event.data.callSession);
13960
+ case SDK_ON_OUTGOING_CALL_MADE:
13961
+ this.onOutgoingCallMade(event.data.callSession);
13931
13962
  break;
13932
13963
  case SDK_CALL_ENDED: {
13933
13964
  const { callSession, content, direction, userExtension } = event.data;
@@ -14018,8 +14049,14 @@ class Softphone {
14018
14049
  case BRIDGE_ON_CARD_CANCELED:
14019
14050
  this.onCardCanceled();
14020
14051
  break;
14021
- case BRIDGE_ON_CALL_ANSWERED:
14022
- this.onCallAnswered();
14052
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14053
+ this.onCallLocallyAnswered(event.data.call);
14054
+ break;
14055
+ case BRIDGE_ON_CALL_REJECTED:
14056
+ this.onCallRejected(event.data.call);
14057
+ break;
14058
+ case BRIDGE_ON_CALL_ESTABLISHED:
14059
+ this.onCallEstablished(event.data.call);
14023
14060
  break;
14024
14061
  default:
14025
14062
  this.onUnHandledEvent(event);
@@ -6005,6 +6005,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6005
6005
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6006
6006
  if (event.candidate) {
6007
6007
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6008
+
6009
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6010
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6011
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6012
+ ice: event.candidate.candidate,
6013
+ });
6014
+ this.iceGatheringComplete();
6015
+ }
6008
6016
  }
6009
6017
  };
6010
6018
 
@@ -13677,7 +13685,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13677
13685
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13678
13686
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13679
13687
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13680
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13688
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13689
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13690
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13681
13691
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13682
13692
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13683
13693
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13694,12 +13704,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13694
13704
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13695
13705
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13696
13706
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13707
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13697
13708
 
13698
13709
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13699
13710
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13700
13711
 
13701
13712
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13702
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13713
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13703
13714
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13704
13715
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13705
13716
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13719,10 +13730,13 @@ class Softphone {
13719
13730
  onLinkEnabled(link ) {}
13720
13731
  onIFrameLoaded() {}
13721
13732
 
13722
- onCallAnswered() {}
13723
- onCallMade(call ) {}
13733
+ onCallLocallyAnswered(call ) {}
13734
+ onCallEstablished(call ) {}
13735
+ onOutgoingCallMade(call ) {}
13724
13736
  onCallIncoming(call ) {}
13737
+ onCallRejected(call ) {}
13725
13738
  onCallEnded(call , card , direction , fromExtension ) {}
13739
+
13726
13740
  onCardSaved(card ) {}
13727
13741
  onCardCanceled() {}
13728
13742
  onAuthenticated(session ) {}
@@ -13754,7 +13768,18 @@ class Softphone {
13754
13768
  onStopRecording() {}
13755
13769
  onUnHandledEvent(event ) {}
13756
13770
 
13757
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13771
+ init({
13772
+ url,
13773
+ width,
13774
+ height,
13775
+ server,
13776
+ port,
13777
+ language,
13778
+ wrapUpDuration,
13779
+ enableAgent = true,
13780
+ tenantId,
13781
+ debug = false,
13782
+ } = {}) {
13758
13783
  this.url = url || 'https://softphone.wazo.io';
13759
13784
  this.width = width || 500;
13760
13785
  this.height = height || 600;
@@ -13766,8 +13791,7 @@ class Softphone {
13766
13791
  window.addEventListener('message', this._onMessage.bind(this), false);
13767
13792
 
13768
13793
  if (!server) {
13769
- // eslint-disable-next-line no-param-reassign
13770
- server = 'stack.dev.wazo.io';
13794
+ throw new Error('`server` is not set');
13771
13795
  }
13772
13796
 
13773
13797
  const config = { server };
@@ -13777,6 +13801,9 @@ class Softphone {
13777
13801
  if (port) {
13778
13802
  config.port = port;
13779
13803
  }
13804
+ if (tenantId) {
13805
+ config.tenantId = tenantId;
13806
+ }
13780
13807
  if (wrapUpDuration) {
13781
13808
  config.wrapUpDuration = wrapUpDuration;
13782
13809
  }
@@ -13787,6 +13814,10 @@ class Softphone {
13787
13814
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13788
13815
  }
13789
13816
 
13817
+ if (debug) {
13818
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13819
+ }
13820
+
13790
13821
  this._createIframe(() => {
13791
13822
  this.iframeLoaded = true;
13792
13823
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13907,8 +13938,8 @@ class Softphone {
13907
13938
  }
13908
13939
 
13909
13940
  switch (event.data.type) {
13910
- case SDK_ON_CALL_MADE:
13911
- this.onCallMade(event.data.callSession);
13941
+ case SDK_ON_OUTGOING_CALL_MADE:
13942
+ this.onOutgoingCallMade(event.data.callSession);
13912
13943
  break;
13913
13944
  case SDK_CALL_ENDED: {
13914
13945
  const { callSession, content, direction, userExtension } = event.data;
@@ -13999,8 +14030,14 @@ class Softphone {
13999
14030
  case BRIDGE_ON_CARD_CANCELED:
14000
14031
  this.onCardCanceled();
14001
14032
  break;
14002
- case BRIDGE_ON_CALL_ANSWERED:
14003
- this.onCallAnswered();
14033
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14034
+ this.onCallLocallyAnswered(event.data.call);
14035
+ break;
14036
+ case BRIDGE_ON_CALL_REJECTED:
14037
+ this.onCallRejected(event.data.call);
14038
+ break;
14039
+ case BRIDGE_ON_CALL_ESTABLISHED:
14040
+ this.onCallEstablished(event.data.call);
14004
14041
  break;
14005
14042
  default:
14006
14043
  this.onUnHandledEvent(event);
@@ -6005,6 +6005,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6005
6005
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6006
6006
  if (event.candidate) {
6007
6007
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6008
+
6009
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6010
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6011
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6012
+ ice: event.candidate.candidate,
6013
+ });
6014
+ this.iceGatheringComplete();
6015
+ }
6008
6016
  }
6009
6017
  };
6010
6018
 
@@ -13585,7 +13593,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13585
13593
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13586
13594
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13587
13595
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13588
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13596
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13597
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13598
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13589
13599
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13590
13600
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13591
13601
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13602,12 +13612,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13602
13612
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13603
13613
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13604
13614
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13615
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13605
13616
 
13606
13617
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13607
13618
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13608
13619
 
13609
13620
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13610
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13621
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13611
13622
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13612
13623
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13613
13624
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13627,10 +13638,13 @@ class Softphone {
13627
13638
  onLinkEnabled(link ) {}
13628
13639
  onIFrameLoaded() {}
13629
13640
 
13630
- onCallAnswered() {}
13631
- onCallMade(call ) {}
13641
+ onCallLocallyAnswered(call ) {}
13642
+ onCallEstablished(call ) {}
13643
+ onOutgoingCallMade(call ) {}
13632
13644
  onCallIncoming(call ) {}
13645
+ onCallRejected(call ) {}
13633
13646
  onCallEnded(call , card , direction , fromExtension ) {}
13647
+
13634
13648
  onCardSaved(card ) {}
13635
13649
  onCardCanceled() {}
13636
13650
  onAuthenticated(session ) {}
@@ -13662,7 +13676,18 @@ class Softphone {
13662
13676
  onStopRecording() {}
13663
13677
  onUnHandledEvent(event ) {}
13664
13678
 
13665
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13679
+ init({
13680
+ url,
13681
+ width,
13682
+ height,
13683
+ server,
13684
+ port,
13685
+ language,
13686
+ wrapUpDuration,
13687
+ enableAgent = true,
13688
+ tenantId,
13689
+ debug = false,
13690
+ } = {}) {
13666
13691
  this.url = url || 'https://softphone.wazo.io';
13667
13692
  this.width = width || 500;
13668
13693
  this.height = height || 600;
@@ -13674,8 +13699,7 @@ class Softphone {
13674
13699
  window.addEventListener('message', this._onMessage.bind(this), false);
13675
13700
 
13676
13701
  if (!server) {
13677
- // eslint-disable-next-line no-param-reassign
13678
- server = 'stack.dev.wazo.io';
13702
+ throw new Error('`server` is not set');
13679
13703
  }
13680
13704
 
13681
13705
  const config = { server };
@@ -13685,6 +13709,9 @@ class Softphone {
13685
13709
  if (port) {
13686
13710
  config.port = port;
13687
13711
  }
13712
+ if (tenantId) {
13713
+ config.tenantId = tenantId;
13714
+ }
13688
13715
  if (wrapUpDuration) {
13689
13716
  config.wrapUpDuration = wrapUpDuration;
13690
13717
  }
@@ -13695,6 +13722,10 @@ class Softphone {
13695
13722
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13696
13723
  }
13697
13724
 
13725
+ if (debug) {
13726
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13727
+ }
13728
+
13698
13729
  this._createIframe(() => {
13699
13730
  this.iframeLoaded = true;
13700
13731
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13815,8 +13846,8 @@ class Softphone {
13815
13846
  }
13816
13847
 
13817
13848
  switch (event.data.type) {
13818
- case SDK_ON_CALL_MADE:
13819
- this.onCallMade(event.data.callSession);
13849
+ case SDK_ON_OUTGOING_CALL_MADE:
13850
+ this.onOutgoingCallMade(event.data.callSession);
13820
13851
  break;
13821
13852
  case SDK_CALL_ENDED: {
13822
13853
  const { callSession, content, direction, userExtension } = event.data;
@@ -13907,8 +13938,14 @@ class Softphone {
13907
13938
  case BRIDGE_ON_CARD_CANCELED:
13908
13939
  this.onCardCanceled();
13909
13940
  break;
13910
- case BRIDGE_ON_CALL_ANSWERED:
13911
- this.onCallAnswered();
13941
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
13942
+ this.onCallLocallyAnswered(event.data.call);
13943
+ break;
13944
+ case BRIDGE_ON_CALL_REJECTED:
13945
+ this.onCallRejected(event.data.call);
13946
+ break;
13947
+ case BRIDGE_ON_CALL_ESTABLISHED:
13948
+ this.onCallEstablished(event.data.call);
13912
13949
  break;
13913
13950
  default:
13914
13951
  this.onUnHandledEvent(event);