@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
@@ -6308,6 +6308,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6308
6308
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6309
6309
  if (event.candidate) {
6310
6310
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6311
+
6312
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6313
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6314
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6315
+ ice: event.candidate.candidate,
6316
+ });
6317
+ this.iceGatheringComplete();
6318
+ }
6311
6319
  }
6312
6320
  };
6313
6321
 
@@ -13161,7 +13169,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13161
13169
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13162
13170
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13163
13171
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13164
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13172
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13173
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13174
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13165
13175
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13166
13176
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13167
13177
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13178,12 +13188,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13178
13188
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13179
13189
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13180
13190
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13191
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13181
13192
 
13182
13193
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13183
13194
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13184
13195
 
13185
13196
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13186
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13197
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13187
13198
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13188
13199
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13189
13200
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13203,10 +13214,13 @@ class Softphone {
13203
13214
  onLinkEnabled(link ) {}
13204
13215
  onIFrameLoaded() {}
13205
13216
 
13206
- onCallAnswered() {}
13207
- onCallMade(call ) {}
13217
+ onCallLocallyAnswered(call ) {}
13218
+ onCallEstablished(call ) {}
13219
+ onOutgoingCallMade(call ) {}
13208
13220
  onCallIncoming(call ) {}
13221
+ onCallRejected(call ) {}
13209
13222
  onCallEnded(call , card , direction , fromExtension ) {}
13223
+
13210
13224
  onCardSaved(card ) {}
13211
13225
  onCardCanceled() {}
13212
13226
  onAuthenticated(session ) {}
@@ -13238,7 +13252,18 @@ class Softphone {
13238
13252
  onStopRecording() {}
13239
13253
  onUnHandledEvent(event ) {}
13240
13254
 
13241
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13255
+ init({
13256
+ url,
13257
+ width,
13258
+ height,
13259
+ server,
13260
+ port,
13261
+ language,
13262
+ wrapUpDuration,
13263
+ enableAgent = true,
13264
+ tenantId,
13265
+ debug = false,
13266
+ } = {}) {
13242
13267
  this.url = url || 'https://softphone.wazo.io';
13243
13268
  this.width = width || 500;
13244
13269
  this.height = height || 600;
@@ -13250,8 +13275,7 @@ class Softphone {
13250
13275
  window.addEventListener('message', this._onMessage.bind(this), false);
13251
13276
 
13252
13277
  if (!server) {
13253
- // eslint-disable-next-line no-param-reassign
13254
- server = 'stack.dev.wazo.io';
13278
+ throw new Error('`server` is not set');
13255
13279
  }
13256
13280
 
13257
13281
  const config = { server };
@@ -13261,6 +13285,9 @@ class Softphone {
13261
13285
  if (port) {
13262
13286
  config.port = port;
13263
13287
  }
13288
+ if (tenantId) {
13289
+ config.tenantId = tenantId;
13290
+ }
13264
13291
  if (wrapUpDuration) {
13265
13292
  config.wrapUpDuration = wrapUpDuration;
13266
13293
  }
@@ -13271,6 +13298,10 @@ class Softphone {
13271
13298
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13272
13299
  }
13273
13300
 
13301
+ if (debug) {
13302
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13303
+ }
13304
+
13274
13305
  this._createIframe(() => {
13275
13306
  this.iframeLoaded = true;
13276
13307
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -13391,8 +13422,8 @@ class Softphone {
13391
13422
  }
13392
13423
 
13393
13424
  switch (event.data.type) {
13394
- case SDK_ON_CALL_MADE:
13395
- this.onCallMade(event.data.callSession);
13425
+ case SDK_ON_OUTGOING_CALL_MADE:
13426
+ this.onOutgoingCallMade(event.data.callSession);
13396
13427
  break;
13397
13428
  case SDK_CALL_ENDED: {
13398
13429
  const { callSession, content, direction, userExtension } = event.data;
@@ -13483,8 +13514,14 @@ class Softphone {
13483
13514
  case BRIDGE_ON_CARD_CANCELED:
13484
13515
  this.onCardCanceled();
13485
13516
  break;
13486
- case BRIDGE_ON_CALL_ANSWERED:
13487
- this.onCallAnswered();
13517
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
13518
+ this.onCallLocallyAnswered(event.data.call);
13519
+ break;
13520
+ case BRIDGE_ON_CALL_REJECTED:
13521
+ this.onCallRejected(event.data.call);
13522
+ break;
13523
+ case BRIDGE_ON_CALL_ESTABLISHED:
13524
+ this.onCallEstablished(event.data.call);
13488
13525
  break;
13489
13526
  default:
13490
13527
  this.onUnHandledEvent(event);
@@ -6306,6 +6306,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6306
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6307
  if (event.candidate) {
6308
6308
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6309
+
6310
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6311
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6312
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6313
+ ice: event.candidate.candidate,
6314
+ });
6315
+ this.iceGatheringComplete();
6316
+ }
6309
6317
  }
6310
6318
  };
6311
6319
 
@@ -13856,7 +13864,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13856
13864
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13857
13865
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13858
13866
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13859
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13867
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13868
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13869
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13860
13870
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13861
13871
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13862
13872
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13873,12 +13883,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13873
13883
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13874
13884
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13875
13885
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13886
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13876
13887
 
13877
13888
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13878
13889
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13879
13890
 
13880
13891
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13881
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13892
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13882
13893
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13883
13894
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13884
13895
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13898,10 +13909,13 @@ class Softphone {
13898
13909
  onLinkEnabled(link ) {}
13899
13910
  onIFrameLoaded() {}
13900
13911
 
13901
- onCallAnswered() {}
13902
- onCallMade(call ) {}
13912
+ onCallLocallyAnswered(call ) {}
13913
+ onCallEstablished(call ) {}
13914
+ onOutgoingCallMade(call ) {}
13903
13915
  onCallIncoming(call ) {}
13916
+ onCallRejected(call ) {}
13904
13917
  onCallEnded(call , card , direction , fromExtension ) {}
13918
+
13905
13919
  onCardSaved(card ) {}
13906
13920
  onCardCanceled() {}
13907
13921
  onAuthenticated(session ) {}
@@ -13933,7 +13947,18 @@ class Softphone {
13933
13947
  onStopRecording() {}
13934
13948
  onUnHandledEvent(event ) {}
13935
13949
 
13936
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13950
+ init({
13951
+ url,
13952
+ width,
13953
+ height,
13954
+ server,
13955
+ port,
13956
+ language,
13957
+ wrapUpDuration,
13958
+ enableAgent = true,
13959
+ tenantId,
13960
+ debug = false,
13961
+ } = {}) {
13937
13962
  this.url = url || 'https://softphone.wazo.io';
13938
13963
  this.width = width || 500;
13939
13964
  this.height = height || 600;
@@ -13945,8 +13970,7 @@ class Softphone {
13945
13970
  window.addEventListener('message', this._onMessage.bind(this), false);
13946
13971
 
13947
13972
  if (!server) {
13948
- // eslint-disable-next-line no-param-reassign
13949
- server = 'stack.dev.wazo.io';
13973
+ throw new Error('`server` is not set');
13950
13974
  }
13951
13975
 
13952
13976
  const config = { server };
@@ -13956,6 +13980,9 @@ class Softphone {
13956
13980
  if (port) {
13957
13981
  config.port = port;
13958
13982
  }
13983
+ if (tenantId) {
13984
+ config.tenantId = tenantId;
13985
+ }
13959
13986
  if (wrapUpDuration) {
13960
13987
  config.wrapUpDuration = wrapUpDuration;
13961
13988
  }
@@ -13966,6 +13993,10 @@ class Softphone {
13966
13993
  this._sendMessage(BRIDGE_ENABLE_AGENT);
13967
13994
  }
13968
13995
 
13996
+ if (debug) {
13997
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
13998
+ }
13999
+
13969
14000
  this._createIframe(() => {
13970
14001
  this.iframeLoaded = true;
13971
14002
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14086,8 +14117,8 @@ class Softphone {
14086
14117
  }
14087
14118
 
14088
14119
  switch (event.data.type) {
14089
- case SDK_ON_CALL_MADE:
14090
- this.onCallMade(event.data.callSession);
14120
+ case SDK_ON_OUTGOING_CALL_MADE:
14121
+ this.onOutgoingCallMade(event.data.callSession);
14091
14122
  break;
14092
14123
  case SDK_CALL_ENDED: {
14093
14124
  const { callSession, content, direction, userExtension } = event.data;
@@ -14178,8 +14209,14 @@ class Softphone {
14178
14209
  case BRIDGE_ON_CARD_CANCELED:
14179
14210
  this.onCardCanceled();
14180
14211
  break;
14181
- case BRIDGE_ON_CALL_ANSWERED:
14182
- this.onCallAnswered();
14212
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14213
+ this.onCallLocallyAnswered(event.data.call);
14214
+ break;
14215
+ case BRIDGE_ON_CALL_REJECTED:
14216
+ this.onCallRejected(event.data.call);
14217
+ break;
14218
+ case BRIDGE_ON_CALL_ESTABLISHED:
14219
+ this.onCallEstablished(event.data.call);
14183
14220
  break;
14184
14221
  default:
14185
14222
  this.onUnHandledEvent(event);
@@ -6306,6 +6306,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6306
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6307
  if (event.candidate) {
6308
6308
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6309
+
6310
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6311
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6312
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6313
+ ice: event.candidate.candidate,
6314
+ });
6315
+ this.iceGatheringComplete();
6316
+ }
6309
6317
  }
6310
6318
  };
6311
6319
 
@@ -13937,7 +13945,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13937
13945
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13938
13946
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13939
13947
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13940
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13948
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13949
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13950
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13941
13951
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13942
13952
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13943
13953
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13954,12 +13964,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13954
13964
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13955
13965
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13956
13966
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13967
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
13957
13968
 
13958
13969
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13959
13970
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13960
13971
 
13961
13972
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13962
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13973
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
13963
13974
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13964
13975
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13965
13976
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -13979,10 +13990,13 @@ class Softphone {
13979
13990
  onLinkEnabled(link ) {}
13980
13991
  onIFrameLoaded() {}
13981
13992
 
13982
- onCallAnswered() {}
13983
- onCallMade(call ) {}
13993
+ onCallLocallyAnswered(call ) {}
13994
+ onCallEstablished(call ) {}
13995
+ onOutgoingCallMade(call ) {}
13984
13996
  onCallIncoming(call ) {}
13997
+ onCallRejected(call ) {}
13985
13998
  onCallEnded(call , card , direction , fromExtension ) {}
13999
+
13986
14000
  onCardSaved(card ) {}
13987
14001
  onCardCanceled() {}
13988
14002
  onAuthenticated(session ) {}
@@ -14014,7 +14028,18 @@ class Softphone {
14014
14028
  onStopRecording() {}
14015
14029
  onUnHandledEvent(event ) {}
14016
14030
 
14017
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14031
+ init({
14032
+ url,
14033
+ width,
14034
+ height,
14035
+ server,
14036
+ port,
14037
+ language,
14038
+ wrapUpDuration,
14039
+ enableAgent = true,
14040
+ tenantId,
14041
+ debug = false,
14042
+ } = {}) {
14018
14043
  this.url = url || 'https://softphone.wazo.io';
14019
14044
  this.width = width || 500;
14020
14045
  this.height = height || 600;
@@ -14026,8 +14051,7 @@ class Softphone {
14026
14051
  window.addEventListener('message', this._onMessage.bind(this), false);
14027
14052
 
14028
14053
  if (!server) {
14029
- // eslint-disable-next-line no-param-reassign
14030
- server = 'stack.dev.wazo.io';
14054
+ throw new Error('`server` is not set');
14031
14055
  }
14032
14056
 
14033
14057
  const config = { server };
@@ -14037,6 +14061,9 @@ class Softphone {
14037
14061
  if (port) {
14038
14062
  config.port = port;
14039
14063
  }
14064
+ if (tenantId) {
14065
+ config.tenantId = tenantId;
14066
+ }
14040
14067
  if (wrapUpDuration) {
14041
14068
  config.wrapUpDuration = wrapUpDuration;
14042
14069
  }
@@ -14047,6 +14074,10 @@ class Softphone {
14047
14074
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14048
14075
  }
14049
14076
 
14077
+ if (debug) {
14078
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14079
+ }
14080
+
14050
14081
  this._createIframe(() => {
14051
14082
  this.iframeLoaded = true;
14052
14083
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14167,8 +14198,8 @@ class Softphone {
14167
14198
  }
14168
14199
 
14169
14200
  switch (event.data.type) {
14170
- case SDK_ON_CALL_MADE:
14171
- this.onCallMade(event.data.callSession);
14201
+ case SDK_ON_OUTGOING_CALL_MADE:
14202
+ this.onOutgoingCallMade(event.data.callSession);
14172
14203
  break;
14173
14204
  case SDK_CALL_ENDED: {
14174
14205
  const { callSession, content, direction, userExtension } = event.data;
@@ -14259,8 +14290,14 @@ class Softphone {
14259
14290
  case BRIDGE_ON_CARD_CANCELED:
14260
14291
  this.onCardCanceled();
14261
14292
  break;
14262
- case BRIDGE_ON_CALL_ANSWERED:
14263
- this.onCallAnswered();
14293
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14294
+ this.onCallLocallyAnswered(event.data.call);
14295
+ break;
14296
+ case BRIDGE_ON_CALL_REJECTED:
14297
+ this.onCallRejected(event.data.call);
14298
+ break;
14299
+ case BRIDGE_ON_CALL_ESTABLISHED:
14300
+ this.onCallEstablished(event.data.call);
14264
14301
  break;
14265
14302
  default:
14266
14303
  this.onUnHandledEvent(event);
@@ -6306,6 +6306,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6306
6306
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6307
6307
  if (event.candidate) {
6308
6308
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6309
+
6310
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6311
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6312
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6313
+ ice: event.candidate.candidate,
6314
+ });
6315
+ this.iceGatheringComplete();
6316
+ }
6309
6317
  }
6310
6318
  };
6311
6319
 
@@ -13995,7 +14003,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13995
14003
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13996
14004
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13997
14005
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13998
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
14006
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
14007
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
14008
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13999
14009
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
14000
14010
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
14001
14011
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -14012,12 +14022,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
14012
14022
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
14013
14023
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14014
14024
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14025
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
14015
14026
 
14016
14027
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14017
14028
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14018
14029
 
14019
14030
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14020
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14031
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
14021
14032
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14022
14033
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14023
14034
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14037,10 +14048,13 @@ class Softphone {
14037
14048
  onLinkEnabled(link ) {}
14038
14049
  onIFrameLoaded() {}
14039
14050
 
14040
- onCallAnswered() {}
14041
- onCallMade(call ) {}
14051
+ onCallLocallyAnswered(call ) {}
14052
+ onCallEstablished(call ) {}
14053
+ onOutgoingCallMade(call ) {}
14042
14054
  onCallIncoming(call ) {}
14055
+ onCallRejected(call ) {}
14043
14056
  onCallEnded(call , card , direction , fromExtension ) {}
14057
+
14044
14058
  onCardSaved(card ) {}
14045
14059
  onCardCanceled() {}
14046
14060
  onAuthenticated(session ) {}
@@ -14072,7 +14086,18 @@ class Softphone {
14072
14086
  onStopRecording() {}
14073
14087
  onUnHandledEvent(event ) {}
14074
14088
 
14075
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14089
+ init({
14090
+ url,
14091
+ width,
14092
+ height,
14093
+ server,
14094
+ port,
14095
+ language,
14096
+ wrapUpDuration,
14097
+ enableAgent = true,
14098
+ tenantId,
14099
+ debug = false,
14100
+ } = {}) {
14076
14101
  this.url = url || 'https://softphone.wazo.io';
14077
14102
  this.width = width || 500;
14078
14103
  this.height = height || 600;
@@ -14084,8 +14109,7 @@ class Softphone {
14084
14109
  window.addEventListener('message', this._onMessage.bind(this), false);
14085
14110
 
14086
14111
  if (!server) {
14087
- // eslint-disable-next-line no-param-reassign
14088
- server = 'stack.dev.wazo.io';
14112
+ throw new Error('`server` is not set');
14089
14113
  }
14090
14114
 
14091
14115
  const config = { server };
@@ -14095,6 +14119,9 @@ class Softphone {
14095
14119
  if (port) {
14096
14120
  config.port = port;
14097
14121
  }
14122
+ if (tenantId) {
14123
+ config.tenantId = tenantId;
14124
+ }
14098
14125
  if (wrapUpDuration) {
14099
14126
  config.wrapUpDuration = wrapUpDuration;
14100
14127
  }
@@ -14105,6 +14132,10 @@ class Softphone {
14105
14132
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14106
14133
  }
14107
14134
 
14135
+ if (debug) {
14136
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14137
+ }
14138
+
14108
14139
  this._createIframe(() => {
14109
14140
  this.iframeLoaded = true;
14110
14141
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14225,8 +14256,8 @@ class Softphone {
14225
14256
  }
14226
14257
 
14227
14258
  switch (event.data.type) {
14228
- case SDK_ON_CALL_MADE:
14229
- this.onCallMade(event.data.callSession);
14259
+ case SDK_ON_OUTGOING_CALL_MADE:
14260
+ this.onOutgoingCallMade(event.data.callSession);
14230
14261
  break;
14231
14262
  case SDK_CALL_ENDED: {
14232
14263
  const { callSession, content, direction, userExtension } = event.data;
@@ -14317,8 +14348,14 @@ class Softphone {
14317
14348
  case BRIDGE_ON_CARD_CANCELED:
14318
14349
  this.onCardCanceled();
14319
14350
  break;
14320
- case BRIDGE_ON_CALL_ANSWERED:
14321
- this.onCallAnswered();
14351
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14352
+ this.onCallLocallyAnswered(event.data.call);
14353
+ break;
14354
+ case BRIDGE_ON_CALL_REJECTED:
14355
+ this.onCallRejected(event.data.call);
14356
+ break;
14357
+ case BRIDGE_ON_CALL_ESTABLISHED:
14358
+ this.onCallEstablished(event.data.call);
14322
14359
  break;
14323
14360
  default:
14324
14361
  this.onUnHandledEvent(event);
@@ -6308,6 +6308,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
6308
6308
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
6309
6309
  if (event.candidate) {
6310
6310
  this.gatheredCandidates.push(parseCandidate$1(event.candidate.candidate));
6311
+
6312
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
6313
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
6314
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
6315
+ ice: event.candidate.candidate,
6316
+ });
6317
+ this.iceGatheringComplete();
6318
+ }
6311
6319
  }
6312
6320
  };
6313
6321
 
@@ -13981,7 +13989,9 @@ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13981
13989
  const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13982
13990
  const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13983
13991
  const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13984
- const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13992
+ const BRIDGE_ON_CALL_LOCALLY_ACCEPTED = 'bridge/BRIDGE_ON_CALL_LOCALLY_ACCEPTED';
13993
+ const BRIDGE_ON_CALL_REJECTED = 'bridge/BRIDGE_ON_CALL_REJECTED';
13994
+ const BRIDGE_ON_CALL_ESTABLISHED = 'bridge/BRIDGE_ON_CALL_ESTABLISHED';
13985
13995
  const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13986
13996
  const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13987
13997
  const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
@@ -13998,12 +14008,13 @@ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13998
14008
  const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13999
14009
  const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
14000
14010
  const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
14011
+ const BRIDGE_ENABLE_DEBUG = 'bridge/BRIDGE_ENABLE_DEBUG';
14001
14012
 
14002
14013
  const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
14003
14014
  const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
14004
14015
 
14005
14016
  const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
14006
- const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
14017
+ const SDK_ON_OUTGOING_CALL_MADE = 'sdk/SDK_ON_OUTGOING_CALL_MADE';
14007
14018
  const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
14008
14019
  const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
14009
14020
  const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
@@ -14023,10 +14034,13 @@ class Softphone {
14023
14034
  onLinkEnabled(link ) {}
14024
14035
  onIFrameLoaded() {}
14025
14036
 
14026
- onCallAnswered() {}
14027
- onCallMade(call ) {}
14037
+ onCallLocallyAnswered(call ) {}
14038
+ onCallEstablished(call ) {}
14039
+ onOutgoingCallMade(call ) {}
14028
14040
  onCallIncoming(call ) {}
14041
+ onCallRejected(call ) {}
14029
14042
  onCallEnded(call , card , direction , fromExtension ) {}
14043
+
14030
14044
  onCardSaved(card ) {}
14031
14045
  onCardCanceled() {}
14032
14046
  onAuthenticated(session ) {}
@@ -14058,7 +14072,18 @@ class Softphone {
14058
14072
  onStopRecording() {}
14059
14073
  onUnHandledEvent(event ) {}
14060
14074
 
14061
- init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14075
+ init({
14076
+ url,
14077
+ width,
14078
+ height,
14079
+ server,
14080
+ port,
14081
+ language,
14082
+ wrapUpDuration,
14083
+ enableAgent = true,
14084
+ tenantId,
14085
+ debug = false,
14086
+ } = {}) {
14062
14087
  this.url = url || 'https://softphone.wazo.io';
14063
14088
  this.width = width || 500;
14064
14089
  this.height = height || 600;
@@ -14070,8 +14095,7 @@ class Softphone {
14070
14095
  window.addEventListener('message', this._onMessage.bind(this), false);
14071
14096
 
14072
14097
  if (!server) {
14073
- // eslint-disable-next-line no-param-reassign
14074
- server = 'stack.dev.wazo.io';
14098
+ throw new Error('`server` is not set');
14075
14099
  }
14076
14100
 
14077
14101
  const config = { server };
@@ -14081,6 +14105,9 @@ class Softphone {
14081
14105
  if (port) {
14082
14106
  config.port = port;
14083
14107
  }
14108
+ if (tenantId) {
14109
+ config.tenantId = tenantId;
14110
+ }
14084
14111
  if (wrapUpDuration) {
14085
14112
  config.wrapUpDuration = wrapUpDuration;
14086
14113
  }
@@ -14091,6 +14118,10 @@ class Softphone {
14091
14118
  this._sendMessage(BRIDGE_ENABLE_AGENT);
14092
14119
  }
14093
14120
 
14121
+ if (debug) {
14122
+ this._sendMessage(BRIDGE_ENABLE_DEBUG);
14123
+ }
14124
+
14094
14125
  this._createIframe(() => {
14095
14126
  this.iframeLoaded = true;
14096
14127
  this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
@@ -14211,8 +14242,8 @@ class Softphone {
14211
14242
  }
14212
14243
 
14213
14244
  switch (event.data.type) {
14214
- case SDK_ON_CALL_MADE:
14215
- this.onCallMade(event.data.callSession);
14245
+ case SDK_ON_OUTGOING_CALL_MADE:
14246
+ this.onOutgoingCallMade(event.data.callSession);
14216
14247
  break;
14217
14248
  case SDK_CALL_ENDED: {
14218
14249
  const { callSession, content, direction, userExtension } = event.data;
@@ -14303,8 +14334,14 @@ class Softphone {
14303
14334
  case BRIDGE_ON_CARD_CANCELED:
14304
14335
  this.onCardCanceled();
14305
14336
  break;
14306
- case BRIDGE_ON_CALL_ANSWERED:
14307
- this.onCallAnswered();
14337
+ case BRIDGE_ON_CALL_LOCALLY_ACCEPTED:
14338
+ this.onCallLocallyAnswered(event.data.call);
14339
+ break;
14340
+ case BRIDGE_ON_CALL_REJECTED:
14341
+ this.onCallRejected(event.data.call);
14342
+ break;
14343
+ case BRIDGE_ON_CALL_ESTABLISHED:
14344
+ this.onCallEstablished(event.data.call);
14308
14345
  break;
14309
14346
  default:
14310
14347
  this.onUnHandledEvent(event);
@@ -887,6 +887,14 @@ class WazoSessionDescriptionHandler extends sessionDescriptionHandler.SessionDes
887
887
  wazoLogger.trace('onicecandidate', event.candidate ? event.candidate.candidate : { done: true });
888
888
  if (event.candidate) {
889
889
  this.gatheredCandidates.push(parseCandidate(event.candidate.candidate));
890
+
891
+ // When receiving a `srflx` or a `relay` candidate, consider the negotiation done.
892
+ if (event.candidate.candidate.indexOf('srflx') !== -1 || event.candidate.candidate.indexOf('relay') !== -1) {
893
+ wazoLogger.info('A valid ice was found, triggering ice gathering complete callback.', {
894
+ ice: event.candidate.candidate,
895
+ });
896
+ this.iceGatheringComplete();
897
+ }
890
898
  }
891
899
  };
892
900