@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
@@ -8326,7 +8326,7 @@ class WebRTCClient extends Emitter {
8326
8326
  }
8327
8327
 
8328
8328
  async _onHeartbeatTimeout() {
8329
- logger$8.info('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8329
+ logger$8.warn('sdk webrtc heartbeat timed out', { userAgent: !!this.userAgent, cb: !!this.heartbeatTimeoutCb });
8330
8330
 
8331
8331
  if (this.heartbeatTimeoutCb) {
8332
8332
  this.heartbeatTimeoutCb();
@@ -13830,6 +13830,365 @@ class Checker {
13830
13830
  }
13831
13831
  }
13832
13832
 
13833
+ //
13834
+ /* eslint-disable no-unused-vars */
13835
+ /* global window, document */
13836
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13837
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13838
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13839
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13840
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13841
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13842
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13843
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13844
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13845
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13846
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13847
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13848
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13849
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13850
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13851
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13852
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13853
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13854
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13855
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13856
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13857
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13858
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13859
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13860
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13861
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13862
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13863
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13864
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13865
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13866
+
13867
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13868
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13869
+
13870
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13871
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13872
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13873
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13874
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13875
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13876
+
13877
+ class Softphone {
13878
+
13879
+
13880
+
13881
+
13882
+
13883
+
13884
+
13885
+ // Message waiting for the iframe to be loaded
13886
+
13887
+
13888
+ onLinkEnabled(link ) {}
13889
+ onIFrameLoaded() {}
13890
+
13891
+ onCallAnswered() {}
13892
+ onCallMade(call ) {}
13893
+ onCallIncoming(call ) {}
13894
+ onCallEnded(call , card , direction , fromExtension ) {}
13895
+ onCardSaved(card ) {}
13896
+ onCardCanceled() {}
13897
+ onAuthenticated(session ) {}
13898
+ onLoggedOut() {}
13899
+
13900
+ onSearchOptions(fieldId , query ) {
13901
+ this.onOptionsResults(fieldId, []);
13902
+ }
13903
+
13904
+ onDisplayLinkedOption(optionId ) {}
13905
+ onWazoContactSearch(query ) {}
13906
+ onAgentLoggedIn() {}
13907
+ onAgentLoggedOut() {}
13908
+ onAgentPaused() {}
13909
+ onAgentResumed() {}
13910
+ onLanguageChanged(language ) {}
13911
+ onCallHeld() {}
13912
+ onCallResumed() {}
13913
+ onCallMuted() {}
13914
+ onCallUnMuted() {}
13915
+ onDtmfSent(tone ) {}
13916
+ onDirectTransfer(number ) {}
13917
+ onCreateIndirectTransfer(number ) {}
13918
+ onCancelIndirectTransfer() {}
13919
+ onConfirmIndirectTransfer() {}
13920
+ onIndirectCallMade(call ) {}
13921
+ onIndirectTransferDone(call ) {}
13922
+ onStartRecording() {}
13923
+ onStopRecording() {}
13924
+ onUnHandledEvent(event ) {}
13925
+
13926
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
13927
+ this.url = url || 'https://softphone.wazo.io';
13928
+ this.width = width || 500;
13929
+ this.height = height || 600;
13930
+ this.displayed = false;
13931
+ this.iframeLoaded = false;
13932
+
13933
+ this.iframeLoaded = false;
13934
+ this._pendingMessages = [];
13935
+ window.addEventListener('message', this._onMessage.bind(this), false);
13936
+
13937
+ if (!server) {
13938
+ // eslint-disable-next-line no-param-reassign
13939
+ server = 'stack.dev.wazo.io';
13940
+ }
13941
+
13942
+ const config = { server };
13943
+ if (language) {
13944
+ config.language = language;
13945
+ }
13946
+ if (port) {
13947
+ config.port = port;
13948
+ }
13949
+ if (wrapUpDuration) {
13950
+ config.wrapUpDuration = wrapUpDuration;
13951
+ }
13952
+
13953
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
13954
+
13955
+ if (enableAgent) {
13956
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
13957
+ }
13958
+
13959
+ this._createIframe(() => {
13960
+ this.iframeLoaded = true;
13961
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
13962
+
13963
+ this.onIFrameLoaded();
13964
+ });
13965
+ }
13966
+
13967
+ parseLinks() {
13968
+ const links = this._getLinks();
13969
+
13970
+ links.forEach(link => {
13971
+ link.setAttribute('data-wazo-parsed', true);
13972
+ link.addEventListener('click', this._onLinkClick.bind(this));
13973
+ this.onLinkEnabled(link);
13974
+ });
13975
+ }
13976
+
13977
+ makeCall(number ) {
13978
+ this.displaySoftphone();
13979
+
13980
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
13981
+ }
13982
+
13983
+ toggleSoftphoneDisplay() {
13984
+ if (this.displayed) {
13985
+ this.hideSoftphone();
13986
+ } else {
13987
+ this.displaySoftphone();
13988
+ }
13989
+ }
13990
+
13991
+ displaySoftphone() {
13992
+ if (!this.iframe) {
13993
+ this._createIframe();
13994
+ }
13995
+
13996
+ if (this.iframe) {
13997
+ this.iframe.style.display = 'block';
13998
+ }
13999
+
14000
+ this.displayed = true;
14001
+ }
14002
+
14003
+ hideSoftphone() {
14004
+ if (this.iframe) {
14005
+ this.iframe.style.display = 'none';
14006
+ }
14007
+ this.displayed = false;
14008
+ }
14009
+
14010
+ optionsFetched(fieldId , options ) {
14011
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14012
+ }
14013
+
14014
+ onOptionsResults(fieldId , options ) {
14015
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14016
+ }
14017
+
14018
+ setFormSchema(schema , uiSchema ) {
14019
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14020
+ }
14021
+
14022
+ setCardValue(field , value ) {
14023
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14024
+ }
14025
+
14026
+ injectCss(css ) {
14027
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14028
+ }
14029
+
14030
+ customizeAppearance(themes , translations , assets ) {
14031
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14032
+ }
14033
+
14034
+ _createIframe(cb = () => {}) {
14035
+ this.iframe = document.createElement('iframe');
14036
+ // $FlowFixMe
14037
+ this.iframe.width = this.width;
14038
+ // $FlowFixMe
14039
+ this.iframe.height = this.height;
14040
+ // $FlowFixMe
14041
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14042
+ this.iframe.style.position = 'absolute';
14043
+ this.iframe.style.left = '0';
14044
+ this.iframe.style.bottom = '0';
14045
+ this.iframe.style.border = '1px solid #aaa';
14046
+ this.iframe.style.backgroundColor = 'white';
14047
+ this.iframe.src = this.url;
14048
+ this.iframe.style.display = 'none';
14049
+ this.iframe.id = 'wazo-softphone';
14050
+
14051
+ this.iframe.onload = cb;
14052
+
14053
+ // $FlowFixMe
14054
+ document.body.appendChild(this.iframe);
14055
+ }
14056
+
14057
+ _getLinks() {
14058
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14059
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14060
+ }
14061
+
14062
+ _onLinkClick(e ) {
14063
+ e.preventDefault();
14064
+ const number = e.target.href.split(':')[1];
14065
+
14066
+ this.makeCall(number);
14067
+ }
14068
+
14069
+ _onAuthenticated() {
14070
+ this.parseLinks();
14071
+ }
14072
+
14073
+ _onMessage(event ) {
14074
+ if (!event.data) {
14075
+ return;
14076
+ }
14077
+
14078
+ switch (event.data.type) {
14079
+ case SDK_ON_CALL_MADE:
14080
+ this.onCallMade(event.data.callSession);
14081
+ break;
14082
+ case SDK_CALL_ENDED: {
14083
+ const { callSession, content, direction, userExtension } = event.data;
14084
+ this.onCallEnded(callSession, content, direction, userExtension);
14085
+ break;
14086
+ }
14087
+ case SDK_CALL_INCOMING:
14088
+ this.onCallIncoming(event.data.callSession);
14089
+ break;
14090
+ case SDK_AUTHENTICATED:
14091
+ // $FlowFixMe
14092
+ this._onAuthenticated(event.data.session);
14093
+ this.onAuthenticated(event.data.session);
14094
+ break;
14095
+ case SDK_LOGGED_OUT:
14096
+ this.onLoggedOut();
14097
+ break;
14098
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14099
+ const { content } = event.data;
14100
+ this.onCardSaved(content);
14101
+ break;
14102
+ }
14103
+ case BRIDGE_SEARCH_OPTIONS: {
14104
+ const { fieldId, query } = event.data;
14105
+ this.onSearchOptions(fieldId, query);
14106
+ break;
14107
+ }
14108
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14109
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14110
+ break;
14111
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14112
+ this.onWazoContactSearch(event.data.query);
14113
+ break;
14114
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14115
+ this.onAgentLoggedIn();
14116
+ break;
14117
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14118
+ this.onAgentLoggedOut();
14119
+ break;
14120
+ case BRIDGE_ON_AGENT_PAUSED:
14121
+ this.onAgentPaused();
14122
+ break;
14123
+ case BRIDGE_ON_AGENT_RESUMED:
14124
+ this.onAgentResumed();
14125
+ break;
14126
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14127
+ this.onLanguageChanged(event.data.language);
14128
+ break;
14129
+ case BRIDGE_ON_CALL_HELD:
14130
+ this.onCallHeld();
14131
+ break;
14132
+ case BRIDGE_ON_CALL_RESUMED:
14133
+ this.onCallResumed();
14134
+ break;
14135
+ case BRIDGE_ON_CALL_MUTED:
14136
+ this.onCallMuted();
14137
+ break;
14138
+ case BRIDGE_ON_CALL_UN_MUTED:
14139
+ this.onCallUnMuted();
14140
+ break;
14141
+ case BRIDGE_ON_DTMF:
14142
+ this.onDtmfSent(event.data.tone);
14143
+ break;
14144
+ case BRIDGE_ON_DIRECT_TRANSFER:
14145
+ this.onDirectTransfer(event.data.number);
14146
+ break;
14147
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14148
+ this.onCreateIndirectTransfer(event.data.number);
14149
+ break;
14150
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14151
+ this.onCancelIndirectTransfer();
14152
+ break;
14153
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14154
+ this.onConfirmIndirectTransfer();
14155
+ break;
14156
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14157
+ this.onIndirectCallMade(event.data.call);
14158
+ break;
14159
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14160
+ this.onIndirectTransferDone(event.data.call);
14161
+ break;
14162
+ case BRIDGE_ON_START_RECORDING:
14163
+ this.onStartRecording();
14164
+ break;
14165
+ case BRIDGE_ON_STOP_RECORDING:
14166
+ this.onStopRecording();
14167
+ break;
14168
+ case BRIDGE_ON_CARD_CANCELED:
14169
+ this.onCardCanceled();
14170
+ break;
14171
+ case BRIDGE_ON_CALL_ANSWERED:
14172
+ this.onCallAnswered();
14173
+ break;
14174
+ default:
14175
+ this.onUnHandledEvent(event);
14176
+ break;
14177
+ }
14178
+ }
14179
+
14180
+ _sendMessage(type , payload = {}) {
14181
+ if (!this.iframe || !this.iframeLoaded) {
14182
+ this._pendingMessages.push([type, payload]);
14183
+ return;
14184
+ }
14185
+
14186
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14187
+ }
14188
+ }
14189
+
14190
+ var Softphone$1 = new Softphone();
14191
+
13833
14192
  /* global window */
13834
14193
 
13835
14194
  const Wazo = {
@@ -13850,6 +14209,7 @@ const Wazo = {
13850
14209
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13851
14210
  Features: Features$1,
13852
14211
  Checker,
14212
+ Softphone: Softphone$1,
13853
14213
 
13854
14214
  // Domain
13855
14215
  domain: {