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