@wazo/sdk 0.37.43 → 0.38.2

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 (46) hide show
  1. package/README.md +246 -0
  2. package/dist/wazo-sdk.js +5 -5
  3. package/esm/__tests__/web-rtc-client.test.js +1 -1
  4. package/esm/checker/Checker.js +1 -1
  5. package/esm/checker/checks/index.js +1 -1
  6. package/esm/checker/checks/webrtc-transport.js +1 -1
  7. package/esm/checker/checks/webrtc.js +1 -1
  8. package/esm/index.js +361 -1
  9. package/esm/simple/Auth.js +361 -1
  10. package/esm/simple/Configuration.js +361 -1
  11. package/esm/simple/Phone.js +361 -1
  12. package/esm/simple/Softphone.js +360 -0
  13. package/esm/simple/index.js +361 -1
  14. package/esm/simple/room/LocalParticipant.js +361 -1
  15. package/esm/simple/room/Participant.js +361 -1
  16. package/esm/simple/room/RemoteParticipant.js +361 -1
  17. package/esm/simple/room/Room.js +361 -1
  18. package/esm/simple/room/SipRoom.js +361 -1
  19. package/esm/simple/room/Stream.js +361 -1
  20. package/esm/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  21. package/esm/simple/utils.js +361 -1
  22. package/esm/web-rtc-client.js +1 -1
  23. package/lib/__tests__/web-rtc-client.test.js +1 -1
  24. package/lib/checker/Checker.js +1 -1
  25. package/lib/checker/checks/index.js +1 -1
  26. package/lib/checker/checks/webrtc-transport.js +1 -1
  27. package/lib/checker/checks/webrtc.js +1 -1
  28. package/lib/index.js +361 -1
  29. package/lib/simple/Auth.js +361 -1
  30. package/lib/simple/Configuration.js +361 -1
  31. package/lib/simple/Phone.js +361 -1
  32. package/lib/simple/Softphone.js +362 -0
  33. package/lib/simple/index.js +361 -1
  34. package/lib/simple/room/LocalParticipant.js +361 -1
  35. package/lib/simple/room/Participant.js +361 -1
  36. package/lib/simple/room/RemoteParticipant.js +361 -1
  37. package/lib/simple/room/Room.js +361 -1
  38. package/lib/simple/room/SipRoom.js +361 -1
  39. package/lib/simple/room/Stream.js +361 -1
  40. package/lib/simple/room/__tests__/RemoteParticipant.test.js +361 -1
  41. package/lib/simple/utils.js +361 -1
  42. package/lib/web-rtc-client.js +1 -1
  43. package/package.json +1 -1
  44. package/src/simple/Softphone.js +358 -0
  45. package/src/simple/index.js +2 -0
  46. package/src/web-rtc-client.js +1 -1
@@ -8025,7 +8025,7 @@ class WebRTCClient extends Emitter {
8025
8025
  }
8026
8026
 
8027
8027
  async _onHeartbeatTimeout() {
8028
- logger$9.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8028
+ logger$9.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8029
8029
 
8030
8030
  if (this.heartbeatTimeoutCb) {
8031
8031
  this.heartbeatTimeoutCb();
@@ -13651,6 +13651,365 @@ class Checker {
13651
13651
  }
13652
13652
  }
13653
13653
 
13654
+ //
13655
+ /* eslint-disable no-unused-vars */
13656
+ /* global window, document */
13657
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13658
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13659
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13660
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13661
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13662
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13663
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13664
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13665
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13666
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13667
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13668
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13669
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13670
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13671
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13672
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13673
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13674
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13675
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13676
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13677
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13678
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13679
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13680
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13681
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13682
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13683
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13684
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13685
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13686
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13687
+
13688
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13689
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13690
+
13691
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13692
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13693
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13694
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13695
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13696
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13697
+
13698
+ class Softphone {
13699
+
13700
+
13701
+
13702
+
13703
+
13704
+
13705
+
13706
+ // Message waiting for the iframe to be loaded
13707
+
13708
+
13709
+ onLinkEnabled(link ) {}
13710
+ onIFrameLoaded() {}
13711
+
13712
+ onCallAnswered() {}
13713
+ onCallMade(call ) {}
13714
+ onCallIncoming(call ) {}
13715
+ onCallEnded(call , card , direction , fromExtension ) {}
13716
+ onCardSaved(card ) {}
13717
+ onCardCanceled() {}
13718
+ onAuthenticated(session ) {}
13719
+ onLoggedOut() {}
13720
+
13721
+ onSearchOptions(fieldId , query ) {
13722
+ this.onOptionsResults(fieldId, []);
13723
+ }
13724
+
13725
+ onDisplayLinkedOption(optionId ) {}
13726
+ onWazoContactSearch(query ) {}
13727
+ onAgentLoggedIn() {}
13728
+ onAgentLoggedOut() {}
13729
+ onAgentPaused() {}
13730
+ onAgentResumed() {}
13731
+ onLanguageChanged(language ) {}
13732
+ onCallHeld() {}
13733
+ onCallResumed() {}
13734
+ onCallMuted() {}
13735
+ onCallUnMuted() {}
13736
+ onDtmfSent(tone ) {}
13737
+ onDirectTransfer(number ) {}
13738
+ onCreateIndirectTransfer(number ) {}
13739
+ onCancelIndirectTransfer() {}
13740
+ onConfirmIndirectTransfer() {}
13741
+ onIndirectCallMade(call ) {}
13742
+ onIndirectTransferDone(call ) {}
13743
+ onStartRecording() {}
13744
+ onStopRecording() {}
13745
+ onUnHandledEvent(event ) {}
13746
+
13747
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13748
+ this.url = url || 'https://softphone.wazo.io';
13749
+ this.width = width || 500;
13750
+ this.height = height || 600;
13751
+ this.displayed = false;
13752
+ this.iframeLoaded = false;
13753
+
13754
+ this.iframeLoaded = false;
13755
+ this._pendingMessages = [];
13756
+ window.addEventListener('message', this._onMessage.bind(this), false);
13757
+
13758
+ if (!server) {
13759
+ // eslint-disable-next-line no-param-reassign
13760
+ server = 'stack.dev.wazo.io';
13761
+ }
13762
+
13763
+ const config = { server };
13764
+ if (language) {
13765
+ config.language = language;
13766
+ }
13767
+ if (port) {
13768
+ config.port = port;
13769
+ }
13770
+ if (wrapUpDuration) {
13771
+ config.wrapUpDuration = wrapUpDuration;
13772
+ }
13773
+
13774
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13775
+
13776
+ if (enableAgent) {
13777
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13778
+ }
13779
+
13780
+ this._createIframe(() => {
13781
+ this.iframeLoaded = true;
13782
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13783
+
13784
+ this.onIFrameLoaded();
13785
+ });
13786
+ }
13787
+
13788
+ parseLinks() {
13789
+ const links = this._getLinks();
13790
+
13791
+ links.forEach(link => {
13792
+ link.setAttribute('data-wazo-parsed', true);
13793
+ link.addEventListener('click', this._onLinkClick.bind(this));
13794
+ this.onLinkEnabled(link);
13795
+ });
13796
+ }
13797
+
13798
+ makeCall(number ) {
13799
+ this.displaySoftphone();
13800
+
13801
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
13802
+ }
13803
+
13804
+ toggleSoftphoneDisplay() {
13805
+ if (this.displayed) {
13806
+ this.hideSoftphone();
13807
+ } else {
13808
+ this.displaySoftphone();
13809
+ }
13810
+ }
13811
+
13812
+ displaySoftphone() {
13813
+ if (!this.iframe) {
13814
+ this._createIframe();
13815
+ }
13816
+
13817
+ if (this.iframe) {
13818
+ this.iframe.style.display = 'block';
13819
+ }
13820
+
13821
+ this.displayed = true;
13822
+ }
13823
+
13824
+ hideSoftphone() {
13825
+ if (this.iframe) {
13826
+ this.iframe.style.display = 'none';
13827
+ }
13828
+ this.displayed = false;
13829
+ }
13830
+
13831
+ optionsFetched(fieldId , options ) {
13832
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
13833
+ }
13834
+
13835
+ onOptionsResults(fieldId , options ) {
13836
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
13837
+ }
13838
+
13839
+ setFormSchema(schema , uiSchema ) {
13840
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13841
+ }
13842
+
13843
+ setCardValue(field , value ) {
13844
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13845
+ }
13846
+
13847
+ injectCss(css ) {
13848
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13849
+ }
13850
+
13851
+ customizeAppearance(themes , translations , assets ) {
13852
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13853
+ }
13854
+
13855
+ _createIframe(cb = () => {}) {
13856
+ this.iframe = document.createElement('iframe');
13857
+ // $FlowFixMe
13858
+ this.iframe.width = this.width;
13859
+ // $FlowFixMe
13860
+ this.iframe.height = this.height;
13861
+ // $FlowFixMe
13862
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13863
+ this.iframe.style.position = 'absolute';
13864
+ this.iframe.style.left = '0';
13865
+ this.iframe.style.bottom = '0';
13866
+ this.iframe.style.border = '1px solid #aaa';
13867
+ this.iframe.style.backgroundColor = 'white';
13868
+ this.iframe.src = this.url;
13869
+ this.iframe.style.display = 'none';
13870
+ this.iframe.id = 'wazo-softphone';
13871
+
13872
+ this.iframe.onload = cb;
13873
+
13874
+ // $FlowFixMe
13875
+ document.body.appendChild(this.iframe);
13876
+ }
13877
+
13878
+ _getLinks() {
13879
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13880
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13881
+ }
13882
+
13883
+ _onLinkClick(e ) {
13884
+ e.preventDefault();
13885
+ const number = e.target.href.split(':')[1];
13886
+
13887
+ this.makeCall(number);
13888
+ }
13889
+
13890
+ _onAuthenticated() {
13891
+ this.parseLinks();
13892
+ }
13893
+
13894
+ _onMessage(event ) {
13895
+ if (!event.data) {
13896
+ return;
13897
+ }
13898
+
13899
+ switch (event.data.type) {
13900
+ case SDK_ON_CALL_MADE:
13901
+ this.onCallMade(event.data.callSession);
13902
+ break;
13903
+ case SDK_CALL_ENDED: {
13904
+ const { callSession, content, direction, userExtension } = event.data;
13905
+ this.onCallEnded(callSession, content, direction, userExtension);
13906
+ break;
13907
+ }
13908
+ case SDK_CALL_INCOMING:
13909
+ this.onCallIncoming(event.data.callSession);
13910
+ break;
13911
+ case SDK_AUTHENTICATED:
13912
+ // $FlowFixMe
13913
+ this._onAuthenticated(event.data.session);
13914
+ this.onAuthenticated(event.data.session);
13915
+ break;
13916
+ case SDK_LOGGED_OUT:
13917
+ this.onLoggedOut();
13918
+ break;
13919
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
13920
+ const { content } = event.data;
13921
+ this.onCardSaved(content);
13922
+ break;
13923
+ }
13924
+ case BRIDGE_SEARCH_OPTIONS: {
13925
+ const { fieldId, query } = event.data;
13926
+ this.onSearchOptions(fieldId, query);
13927
+ break;
13928
+ }
13929
+ case BRIDGE_DISPLAY_LINKED_OPTION:
13930
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
13931
+ break;
13932
+ case BRIDGE_WAZO_CONTACT_SEARCH:
13933
+ this.onWazoContactSearch(event.data.query);
13934
+ break;
13935
+ case BRIDGE_ON_AGENT_LOGGED_IN:
13936
+ this.onAgentLoggedIn();
13937
+ break;
13938
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
13939
+ this.onAgentLoggedOut();
13940
+ break;
13941
+ case BRIDGE_ON_AGENT_PAUSED:
13942
+ this.onAgentPaused();
13943
+ break;
13944
+ case BRIDGE_ON_AGENT_RESUMED:
13945
+ this.onAgentResumed();
13946
+ break;
13947
+ case BRIDGE_ON_LANGUAGE_CHANGED:
13948
+ this.onLanguageChanged(event.data.language);
13949
+ break;
13950
+ case BRIDGE_ON_CALL_HELD:
13951
+ this.onCallHeld();
13952
+ break;
13953
+ case BRIDGE_ON_CALL_RESUMED:
13954
+ this.onCallResumed();
13955
+ break;
13956
+ case BRIDGE_ON_CALL_MUTED:
13957
+ this.onCallMuted();
13958
+ break;
13959
+ case BRIDGE_ON_CALL_UN_MUTED:
13960
+ this.onCallUnMuted();
13961
+ break;
13962
+ case BRIDGE_ON_DTMF:
13963
+ this.onDtmfSent(event.data.tone);
13964
+ break;
13965
+ case BRIDGE_ON_DIRECT_TRANSFER:
13966
+ this.onDirectTransfer(event.data.number);
13967
+ break;
13968
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
13969
+ this.onCreateIndirectTransfer(event.data.number);
13970
+ break;
13971
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
13972
+ this.onCancelIndirectTransfer();
13973
+ break;
13974
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
13975
+ this.onConfirmIndirectTransfer();
13976
+ break;
13977
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
13978
+ this.onIndirectCallMade(event.data.call);
13979
+ break;
13980
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
13981
+ this.onIndirectTransferDone(event.data.call);
13982
+ break;
13983
+ case BRIDGE_ON_START_RECORDING:
13984
+ this.onStartRecording();
13985
+ break;
13986
+ case BRIDGE_ON_STOP_RECORDING:
13987
+ this.onStopRecording();
13988
+ break;
13989
+ case BRIDGE_ON_CARD_CANCELED:
13990
+ this.onCardCanceled();
13991
+ break;
13992
+ case BRIDGE_ON_CALL_ANSWERED:
13993
+ this.onCallAnswered();
13994
+ break;
13995
+ default:
13996
+ this.onUnHandledEvent(event);
13997
+ break;
13998
+ }
13999
+ }
14000
+
14001
+ _sendMessage(type , payload = {}) {
14002
+ if (!this.iframe || !this.iframeLoaded) {
14003
+ this._pendingMessages.push([type, payload]);
14004
+ return;
14005
+ }
14006
+
14007
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14008
+ }
14009
+ }
14010
+
14011
+ var Softphone$1 = new Softphone();
14012
+
13654
14013
  /* global window */
13655
14014
 
13656
14015
  const Wazo = {
@@ -13671,6 +14030,7 @@ const Wazo = {
13671
14030
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13672
14031
  Features: Features$1,
13673
14032
  Checker,
14033
+ Softphone: Softphone$1,
13674
14034
 
13675
14035
  // Domain
13676
14036
  domain: {