@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
@@ -6296,6 +6296,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6296
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6297
  if (event.candidate) {
6298
6298
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6299
+
6300
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6301
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6302
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6303
+ ice: event.candidate.candidate,
6304
+ });
6305
+ this.iceGatheringComplete();
6306
+ }
6299
6307
  }
6300
6308
  };
6301
6309
 
@@ -13149,7 +13157,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13149
13157
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13150
13158
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13151
13159
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13152
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13160
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13161
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13162
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13153
13163
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13154
13164
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13155
13165
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13166,12 +13176,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13166
13176
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13167
13177
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13168
13178
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13179
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13169
13180
 
13170
13181
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13171
13182
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13172
13183
 
13173
13184
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13174
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13185
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13175
13186
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13176
13187
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13177
13188
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13191,10 +13202,13 @@ class Softphone {
13191
13202
  onLinkEnabled(link ) {}
13192
13203
  onIFrameLoaded() {}
13193
13204
 
13194
- onCallAnswered() {}
13195
- onCallMade(call ) {}
13205
+ onCallLocallyAnswered(call ) {}
13206
+ onCallEstablished(call ) {}
13207
+ onOutgoingCallMade(call ) {}
13196
13208
  onCallIncoming(call ) {}
13209
+ onCallRejected(call ) {}
13197
13210
  onCallEnded(call , card , direction , fromExtension ) {}
13211
+
13198
13212
  onCardSaved(card ) {}
13199
13213
  onCardCanceled() {}
13200
13214
  onAuthenticated(session ) {}
@@ -13226,7 +13240,18 @@ class Softphone {
13226
13240
  onStopRecording() {}
13227
13241
  onUnHandledEvent(event ) {}
13228
13242
 
13229
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13243
+ init({
13244
+ url,
13245
+ width,
13246
+ height,
13247
+ server,
13248
+ port,
13249
+ language,
13250
+ wrapUpDuration,
13251
+ enableAgent = true,
13252
+ tenantId,
13253
+ debug = false,
13254
+ } = {}) {
13230
13255
  this.url = url || 'https://softphone.wazo.io';
13231
13256
  this.width = width || 500;
13232
13257
  this.height = height || 600;
@@ -13238,8 +13263,7 @@ class Softphone {
13238
13263
  window.addEventListener('message', this._onMessage.bind(this), false);
13239
13264
 
13240
13265
  if (!server) {
13241
- // eslint-disable-next-line no-param-reassign
13242
- server = 'stack.dev.wazo.io';
13266
+ throw new Error('`server` is not set');
13243
13267
  }
13244
13268
 
13245
13269
  const config = { server };
@@ -13249,6 +13273,9 @@ class Softphone {
13249
13273
  if (port) {
13250
13274
  config.port = port;
13251
13275
  }
13276
+ if (tenantId) {
13277
+ config.tenantId = tenantId;
13278
+ }
13252
13279
  if (wrapUpDuration) {
13253
13280
  config.wrapUpDuration = wrapUpDuration;
13254
13281
  }
@@ -13259,6 +13286,10 @@ class Softphone {
13259
13286
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13260
13287
  }
13261
13288
 
13289
+ if (debug) {
13290
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13291
+ }
13292
+
13262
13293
  this._createIframe(() => {
13263
13294
  this.iframeLoaded = true;
13264
13295
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13379,8 +13410,8 @@ class Softphone {
13379
13410
  }
13380
13411
 
13381
13412
  switch (event.data.type) {
13382
- case SDK_ON_CALL_MADE:
13383
- this.onCallMade(event.data.callSession);
13413
+ case SDK_ON_OUTGOING_CALL_MADE:
13414
+ this.onOutgoingCallMade(event.data.callSession);
13384
13415
  break;
13385
13416
  case SDK_CALL_ENDED: {
13386
13417
  const { callSession, content, direction, userExtension } = event.data;
@@ -13471,8 +13502,14 @@ class Softphone {
13471
13502
  case BRIDGE_ON_CARD_CANCELED:
13472
13503
  this.onCardCanceled();
13473
13504
  break;
13474
- case BRIDGE_ON_CALL_ANSWERED:
13475
- this.onCallAnswered();
13505
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
13506
+ this.onCallLocallyAnswered(event.data.call);
13507
+ break;
13508
+ case BRIDGE_ON_CALL_REJECTED:
13509
+ this.onCallRejected(event.data.call);
13510
+ break;
13511
+ case BRIDGE_ON_CALL_ESTABLISHED:
13512
+ this.onCallEstablished(event.data.call);
13476
13513
  break;
13477
13514
  default:
13478
13515
  this.onUnHandledEvent(event);
@@ -6296,6 +6296,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6296
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6297
  if (event.candidate) {
6298
6298
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6299
+
6300
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6301
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6302
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6303
+ ice: event.candidate.candidate,
6304
+ });
6305
+ this.iceGatheringComplete();
6306
+ }
6299
6307
  }
6300
6308
  };
6301
6309
 
@@ -13846,7 +13854,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13846
13854
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13847
13855
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13848
13856
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13849
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13857
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13858
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13859
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13850
13860
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13851
13861
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13852
13862
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13863,12 +13873,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13863
13873
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13864
13874
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13865
13875
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13876
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13866
13877
 
13867
13878
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13868
13879
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13869
13880
 
13870
13881
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13871
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13882
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13872
13883
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13873
13884
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13874
13885
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13888,10 +13899,13 @@ class Softphone {
13888
13899
  onLinkEnabled(link ) {}
13889
13900
  onIFrameLoaded() {}
13890
13901
 
13891
- onCallAnswered() {}
13892
- onCallMade(call ) {}
13902
+ onCallLocallyAnswered(call ) {}
13903
+ onCallEstablished(call ) {}
13904
+ onOutgoingCallMade(call ) {}
13893
13905
  onCallIncoming(call ) {}
13906
+ onCallRejected(call ) {}
13894
13907
  onCallEnded(call , card , direction , fromExtension ) {}
13908
+
13895
13909
  onCardSaved(card ) {}
13896
13910
  onCardCanceled() {}
13897
13911
  onAuthenticated(session ) {}
@@ -13923,7 +13937,18 @@ class Softphone {
13923
13937
  onStopRecording() {}
13924
13938
  onUnHandledEvent(event ) {}
13925
13939
 
13926
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13940
+ init({
13941
+ url,
13942
+ width,
13943
+ height,
13944
+ server,
13945
+ port,
13946
+ language,
13947
+ wrapUpDuration,
13948
+ enableAgent = true,
13949
+ tenantId,
13950
+ debug = false,
13951
+ } = {}) {
13927
13952
  this.url = url || 'https://softphone.wazo.io';
13928
13953
  this.width = width || 500;
13929
13954
  this.height = height || 600;
@@ -13935,8 +13960,7 @@ class Softphone {
13935
13960
  window.addEventListener('message', this._onMessage.bind(this), false);
13936
13961
 
13937
13962
  if (!server) {
13938
- // eslint-disable-next-line no-param-reassign
13939
- server = 'stack.dev.wazo.io';
13963
+ throw new Error('`server` is not set');
13940
13964
  }
13941
13965
 
13942
13966
  const config = { server };
@@ -13946,6 +13970,9 @@ class Softphone {
13946
13970
  if (port) {
13947
13971
  config.port = port;
13948
13972
  }
13973
+ if (tenantId) {
13974
+ config.tenantId = tenantId;
13975
+ }
13949
13976
  if (wrapUpDuration) {
13950
13977
  config.wrapUpDuration = wrapUpDuration;
13951
13978
  }
@@ -13956,6 +13983,10 @@ class Softphone {
13956
13983
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13957
13984
  }
13958
13985
 
13986
+ if (debug) {
13987
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13988
+ }
13989
+
13959
13990
  this._createIframe(() => {
13960
13991
  this.iframeLoaded = true;
13961
13992
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14076,8 +14107,8 @@ class Softphone {
14076
14107
  }
14077
14108
 
14078
14109
  switch (event.data.type) {
14079
- case SDK_ON_CALL_MADE:
14080
- this.onCallMade(event.data.callSession);
14110
+ case SDK_ON_OUTGOING_CALL_MADE:
14111
+ this.onOutgoingCallMade(event.data.callSession);
14081
14112
  break;
14082
14113
  case SDK_CALL_ENDED: {
14083
14114
  const { callSession, content, direction, userExtension } = event.data;
@@ -14168,8 +14199,14 @@ class Softphone {
14168
14199
  case BRIDGE_ON_CARD_CANCELED:
14169
14200
  this.onCardCanceled();
14170
14201
  break;
14171
- case BRIDGE_ON_CALL_ANSWERED:
14172
- this.onCallAnswered();
14202
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14203
+ this.onCallLocallyAnswered(event.data.call);
14204
+ break;
14205
+ case BRIDGE_ON_CALL_REJECTED:
14206
+ this.onCallRejected(event.data.call);
14207
+ break;
14208
+ case BRIDGE_ON_CALL_ESTABLISHED:
14209
+ this.onCallEstablished(event.data.call);
14173
14210
  break;
14174
14211
  default:
14175
14212
  this.onUnHandledEvent(event);
@@ -6296,6 +6296,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6296
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6297
  if (event.candidate) {
6298
6298
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6299
+
6300
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6301
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6302
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6303
+ ice: event.candidate.candidate,
6304
+ });
6305
+ this.iceGatheringComplete();
6306
+ }
6299
6307
  }
6300
6308
  };
6301
6309
 
@@ -13927,7 +13935,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13927
13935
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13928
13936
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13929
13937
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13930
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13938
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13939
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13940
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13931
13941
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13932
13942
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13933
13943
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13944,12 +13954,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13944
13954
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13945
13955
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13946
13956
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13957
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13947
13958
 
13948
13959
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13949
13960
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13950
13961
 
13951
13962
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13952
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13963
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13953
13964
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13954
13965
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13955
13966
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13969,10 +13980,13 @@ class Softphone {
13969
13980
  onLinkEnabled(link ) {}
13970
13981
  onIFrameLoaded() {}
13971
13982
 
13972
- onCallAnswered() {}
13973
- onCallMade(call ) {}
13983
+ onCallLocallyAnswered(call ) {}
13984
+ onCallEstablished(call ) {}
13985
+ onOutgoingCallMade(call ) {}
13974
13986
  onCallIncoming(call ) {}
13987
+ onCallRejected(call ) {}
13975
13988
  onCallEnded(call , card , direction , fromExtension ) {}
13989
+
13976
13990
  onCardSaved(card ) {}
13977
13991
  onCardCanceled() {}
13978
13992
  onAuthenticated(session ) {}
@@ -14004,7 +14018,18 @@ class Softphone {
14004
14018
  onStopRecording() {}
14005
14019
  onUnHandledEvent(event ) {}
14006
14020
 
14007
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14021
+ init({
14022
+ url,
14023
+ width,
14024
+ height,
14025
+ server,
14026
+ port,
14027
+ language,
14028
+ wrapUpDuration,
14029
+ enableAgent = true,
14030
+ tenantId,
14031
+ debug = false,
14032
+ } = {}) {
14008
14033
  this.url = url || 'https://softphone.wazo.io';
14009
14034
  this.width = width || 500;
14010
14035
  this.height = height || 600;
@@ -14016,8 +14041,7 @@ class Softphone {
14016
14041
  window.addEventListener('message', this._onMessage.bind(this), false);
14017
14042
 
14018
14043
  if (!server) {
14019
- // eslint-disable-next-line no-param-reassign
14020
- server = 'stack.dev.wazo.io';
14044
+ throw new Error('`server` is not set');
14021
14045
  }
14022
14046
 
14023
14047
  const config = { server };
@@ -14027,6 +14051,9 @@ class Softphone {
14027
14051
  if (port) {
14028
14052
  config.port = port;
14029
14053
  }
14054
+ if (tenantId) {
14055
+ config.tenantId = tenantId;
14056
+ }
14030
14057
  if (wrapUpDuration) {
14031
14058
  config.wrapUpDuration = wrapUpDuration;
14032
14059
  }
@@ -14037,6 +14064,10 @@ class Softphone {
14037
14064
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14038
14065
  }
14039
14066
 
14067
+ if (debug) {
14068
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14069
+ }
14070
+
14040
14071
  this._createIframe(() => {
14041
14072
  this.iframeLoaded = true;
14042
14073
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14157,8 +14188,8 @@ class Softphone {
14157
14188
  }
14158
14189
 
14159
14190
  switch (event.data.type) {
14160
- case SDK_ON_CALL_MADE:
14161
- this.onCallMade(event.data.callSession);
14191
+ case SDK_ON_OUTGOING_CALL_MADE:
14192
+ this.onOutgoingCallMade(event.data.callSession);
14162
14193
  break;
14163
14194
  case SDK_CALL_ENDED: {
14164
14195
  const { callSession, content, direction, userExtension } = event.data;
@@ -14249,8 +14280,14 @@ class Softphone {
14249
14280
  case BRIDGE_ON_CARD_CANCELED:
14250
14281
  this.onCardCanceled();
14251
14282
  break;
14252
- case BRIDGE_ON_CALL_ANSWERED:
14253
- this.onCallAnswered();
14283
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14284
+ this.onCallLocallyAnswered(event.data.call);
14285
+ break;
14286
+ case BRIDGE_ON_CALL_REJECTED:
14287
+ this.onCallRejected(event.data.call);
14288
+ break;
14289
+ case BRIDGE_ON_CALL_ESTABLISHED:
14290
+ this.onCallEstablished(event.data.call);
14254
14291
  break;
14255
14292
  default:
14256
14293
  this.onUnHandledEvent(event);
@@ -6296,6 +6296,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6296
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6297
  if (event.candidate) {
6298
6298
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6299
+
6300
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6301
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6302
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6303
+ ice: event.candidate.candidate,
6304
+ });
6305
+ this.iceGatheringComplete();
6306
+ }
6299
6307
  }
6300
6308
  };
6301
6309
 
@@ -13985,7 +13993,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13985
13993
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13986
13994
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13987
13995
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13988
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13996
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13997
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13998
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13989
13999
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13990
14000
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13991
14001
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14002,12 +14012,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14002
14012
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14003
14013
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14004
14014
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14015
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
14005
14016
 
14006
14017
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14007
14018
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14008
14019
 
14009
14020
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14010
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14021
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
14011
14022
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14012
14023
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14013
14024
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14027,10 +14038,13 @@ class Softphone {
14027
14038
  onLinkEnabled(link ) {}
14028
14039
  onIFrameLoaded() {}
14029
14040
 
14030
- onCallAnswered() {}
14031
- onCallMade(call ) {}
14041
+ onCallLocallyAnswered(call ) {}
14042
+ onCallEstablished(call ) {}
14043
+ onOutgoingCallMade(call ) {}
14032
14044
  onCallIncoming(call ) {}
14045
+ onCallRejected(call ) {}
14033
14046
  onCallEnded(call , card , direction , fromExtension ) {}
14047
+
14034
14048
  onCardSaved(card ) {}
14035
14049
  onCardCanceled() {}
14036
14050
  onAuthenticated(session ) {}
@@ -14062,7 +14076,18 @@ class Softphone {
14062
14076
  onStopRecording() {}
14063
14077
  onUnHandledEvent(event ) {}
14064
14078
 
14065
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14079
+ init({
14080
+ url,
14081
+ width,
14082
+ height,
14083
+ server,
14084
+ port,
14085
+ language,
14086
+ wrapUpDuration,
14087
+ enableAgent = true,
14088
+ tenantId,
14089
+ debug = false,
14090
+ } = {}) {
14066
14091
  this.url = url || 'https://softphone.wazo.io';
14067
14092
  this.width = width || 500;
14068
14093
  this.height = height || 600;
@@ -14074,8 +14099,7 @@ class Softphone {
14074
14099
  window.addEventListener('message', this._onMessage.bind(this), false);
14075
14100
 
14076
14101
  if (!server) {
14077
- // eslint-disable-next-line no-param-reassign
14078
- server = 'stack.dev.wazo.io';
14102
+ throw new Error('`server` is not set');
14079
14103
  }
14080
14104
 
14081
14105
  const config = { server };
@@ -14085,6 +14109,9 @@ class Softphone {
14085
14109
  if (port) {
14086
14110
  config.port = port;
14087
14111
  }
14112
+ if (tenantId) {
14113
+ config.tenantId = tenantId;
14114
+ }
14088
14115
  if (wrapUpDuration) {
14089
14116
  config.wrapUpDuration = wrapUpDuration;
14090
14117
  }
@@ -14095,6 +14122,10 @@ class Softphone {
14095
14122
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14096
14123
  }
14097
14124
 
14125
+ if (debug) {
14126
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14127
+ }
14128
+
14098
14129
  this._createIframe(() => {
14099
14130
  this.iframeLoaded = true;
14100
14131
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14215,8 +14246,8 @@ class Softphone {
14215
14246
  }
14216
14247
 
14217
14248
  switch (event.data.type) {
14218
- case SDK_ON_CALL_MADE:
14219
- this.onCallMade(event.data.callSession);
14249
+ case SDK_ON_OUTGOING_CALL_MADE:
14250
+ this.onOutgoingCallMade(event.data.callSession);
14220
14251
  break;
14221
14252
  case SDK_CALL_ENDED: {
14222
14253
  const { callSession, content, direction, userExtension } = event.data;
@@ -14307,8 +14338,14 @@ class Softphone {
14307
14338
  case BRIDGE_ON_CARD_CANCELED:
14308
14339
  this.onCardCanceled();
14309
14340
  break;
14310
- case BRIDGE_ON_CALL_ANSWERED:
14311
- this.onCallAnswered();
14341
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14342
+ this.onCallLocallyAnswered(event.data.call);
14343
+ break;
14344
+ case BRIDGE_ON_CALL_REJECTED:
14345
+ this.onCallRejected(event.data.call);
14346
+ break;
14347
+ case BRIDGE_ON_CALL_ESTABLISHED:
14348
+ this.onCallEstablished(event.data.call);
14312
14349
  break;
14313
14350
  default:
14314
14351
  this.onUnHandledEvent(event);
@@ -6296,6 +6296,14 @@ class WazoSessionDescriptionHandler extends SessionDescriptionHandler {
6296
6296
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6297
6297
  if (event.candidate) {
6298
6298
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6299
+
6300
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6301
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6302
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6303
+ ice: event.candidate.candidate,
6304
+ });
6305
+ this.iceGatheringComplete();
6306
+ }
6299
6307
  }
6300
6308
  };
6301
6309
 
@@ -13969,7 +13977,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13969
13977
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13970
13978
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13971
13979
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13972
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13980
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13981
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13982
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13973
13983
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13974
13984
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13975
13985
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13986,12 +13996,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13986
13996
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13987
13997
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13988
13998
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13999
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13989
14000
 
13990
14001
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13991
14002
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13992
14003
 
13993
14004
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13994
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14005
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13995
14006
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13996
14007
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13997
14008
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14011,10 +14022,13 @@ class Softphone {
14011
14022
  onLinkEnabled(link ) {}
14012
14023
  onIFrameLoaded() {}
14013
14024
 
14014
- onCallAnswered() {}
14015
- onCallMade(call ) {}
14025
+ onCallLocallyAnswered(call ) {}
14026
+ onCallEstablished(call ) {}
14027
+ onOutgoingCallMade(call ) {}
14016
14028
  onCallIncoming(call ) {}
14029
+ onCallRejected(call ) {}
14017
14030
  onCallEnded(call , card , direction , fromExtension ) {}
14031
+
14018
14032
  onCardSaved(card ) {}
14019
14033
  onCardCanceled() {}
14020
14034
  onAuthenticated(session ) {}
@@ -14046,7 +14060,18 @@ class Softphone {
14046
14060
  onStopRecording() {}
14047
14061
  onUnHandledEvent(event ) {}
14048
14062
 
14049
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14063
+ init({
14064
+ url,
14065
+ width,
14066
+ height,
14067
+ server,
14068
+ port,
14069
+ language,
14070
+ wrapUpDuration,
14071
+ enableAgent = true,
14072
+ tenantId,
14073
+ debug = false,
14074
+ } = {}) {
14050
14075
  this.url = url || 'https://softphone.wazo.io';
14051
14076
  this.width = width || 500;
14052
14077
  this.height = height || 600;
@@ -14058,8 +14083,7 @@ class Softphone {
14058
14083
  window.addEventListener('message', this._onMessage.bind(this), false);
14059
14084
 
14060
14085
  if (!server) {
14061
- // eslint-disable-next-line no-param-reassign
14062
- server = 'stack.dev.wazo.io';
14086
+ throw new Error('`server` is not set');
14063
14087
  }
14064
14088
 
14065
14089
  const config = { server };
@@ -14069,6 +14093,9 @@ class Softphone {
14069
14093
  if (port) {
14070
14094
  config.port = port;
14071
14095
  }
14096
+ if (tenantId) {
14097
+ config.tenantId = tenantId;
14098
+ }
14072
14099
  if (wrapUpDuration) {
14073
14100
  config.wrapUpDuration = wrapUpDuration;
14074
14101
  }
@@ -14079,6 +14106,10 @@ class Softphone {
14079
14106
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14080
14107
  }
14081
14108
 
14109
+ if (debug) {
14110
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14111
+ }
14112
+
14082
14113
  this._createIframe(() => {
14083
14114
  this.iframeLoaded = true;
14084
14115
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14199,8 +14230,8 @@ class Softphone {
14199
14230
  }
14200
14231
 
14201
14232
  switch (event.data.type) {
14202
- case SDK_ON_CALL_MADE:
14203
- this.onCallMade(event.data.callSession);
14233
+ case SDK_ON_OUTGOING_CALL_MADE:
14234
+ this.onOutgoingCallMade(event.data.callSession);
14204
14235
  break;
14205
14236
  case SDK_CALL_ENDED: {
14206
14237
  const { callSession, content, direction, userExtension } = event.data;
@@ -14291,8 +14322,14 @@ class Softphone {
14291
14322
  case BRIDGE_ON_CARD_CANCELED:
14292
14323
  this.onCardCanceled();
14293
14324
  break;
14294
- case BRIDGE_ON_CALL_ANSWERED:
14295
- this.onCallAnswered();
14325
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14326
+ this.onCallLocallyAnswered(event.data.call);
14327
+ break;
14328
+ case BRIDGE_ON_CALL_REJECTED:
14329
+ this.onCallRejected(event.data.call);
14330
+ break;
14331
+ case BRIDGE_ON_CALL_ESTABLISHED:
14332
+ this.onCallEstablished(event.data.call);
14296
14333
  break;
14297
14334
  default:
14298
14335
  this.onUnHandledEvent(event);
@@ -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