@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();
@@ -12843,6 +12843,365 @@ class Checker {
12843
12843
  }
12844
12844
  }
12845
12845
 
12846
+ //
12847
+ /* eslint-disable no-unused-vars */
12848
+ /* global window, document */
12849
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
12850
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
12851
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
12852
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
12853
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
12854
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
12855
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
12856
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
12857
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
12858
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
12859
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
12860
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
12861
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
12862
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
12863
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
12864
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
12865
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
12866
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
12867
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
12868
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
12869
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
12870
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
12871
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
12872
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
12873
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
12874
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
12875
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
12876
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
12877
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
12878
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
12879
+
12880
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
12881
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
12882
+
12883
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
12884
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
12885
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
12886
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
12887
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
12888
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
12889
+
12890
+ class Softphone {
12891
+
12892
+
12893
+
12894
+
12895
+
12896
+
12897
+
12898
+ // Message waiting for the iframe to be loaded
12899
+
12900
+
12901
+ onLinkEnabled(link ) {}
12902
+ onIFrameLoaded() {}
12903
+
12904
+ onCallAnswered() {}
12905
+ onCallMade(call ) {}
12906
+ onCallIncoming(call ) {}
12907
+ onCallEnded(call , card , direction , fromExtension ) {}
12908
+ onCardSaved(card ) {}
12909
+ onCardCanceled() {}
12910
+ onAuthenticated(session ) {}
12911
+ onLoggedOut() {}
12912
+
12913
+ onSearchOptions(fieldId , query ) {
12914
+ this.onOptionsResults(fieldId, []);
12915
+ }
12916
+
12917
+ onDisplayLinkedOption(optionId ) {}
12918
+ onWazoContactSearch(query ) {}
12919
+ onAgentLoggedIn() {}
12920
+ onAgentLoggedOut() {}
12921
+ onAgentPaused() {}
12922
+ onAgentResumed() {}
12923
+ onLanguageChanged(language ) {}
12924
+ onCallHeld() {}
12925
+ onCallResumed() {}
12926
+ onCallMuted() {}
12927
+ onCallUnMuted() {}
12928
+ onDtmfSent(tone ) {}
12929
+ onDirectTransfer(number ) {}
12930
+ onCreateIndirectTransfer(number ) {}
12931
+ onCancelIndirectTransfer() {}
12932
+ onConfirmIndirectTransfer() {}
12933
+ onIndirectCallMade(call ) {}
12934
+ onIndirectTransferDone(call ) {}
12935
+ onStartRecording() {}
12936
+ onStopRecording() {}
12937
+ onUnHandledEvent(event ) {}
12938
+
12939
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
12940
+ this.url = url || 'https://softphone.wazo.io';
12941
+ this.width = width || 500;
12942
+ this.height = height || 600;
12943
+ this.displayed = false;
12944
+ this.iframeLoaded = false;
12945
+
12946
+ this.iframeLoaded = false;
12947
+ this._pendingMessages = [];
12948
+ window.addEventListener('message', this._onMessage.bind(this), false);
12949
+
12950
+ if (!server) {
12951
+ // eslint-disable-next-line no-param-reassign
12952
+ server = 'stack.dev.wazo.io';
12953
+ }
12954
+
12955
+ const config = { server };
12956
+ if (language) {
12957
+ config.language = language;
12958
+ }
12959
+ if (port) {
12960
+ config.port = port;
12961
+ }
12962
+ if (wrapUpDuration) {
12963
+ config.wrapUpDuration = wrapUpDuration;
12964
+ }
12965
+
12966
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
12967
+
12968
+ if (enableAgent) {
12969
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
12970
+ }
12971
+
12972
+ this._createIframe(() => {
12973
+ this.iframeLoaded = true;
12974
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
12975
+
12976
+ this.onIFrameLoaded();
12977
+ });
12978
+ }
12979
+
12980
+ parseLinks() {
12981
+ const links = this._getLinks();
12982
+
12983
+ links.forEach(link => {
12984
+ link.setAttribute('data-wazo-parsed', true);
12985
+ link.addEventListener('click', this._onLinkClick.bind(this));
12986
+ this.onLinkEnabled(link);
12987
+ });
12988
+ }
12989
+
12990
+ makeCall(number ) {
12991
+ this.displaySoftphone();
12992
+
12993
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
12994
+ }
12995
+
12996
+ toggleSoftphoneDisplay() {
12997
+ if (this.displayed) {
12998
+ this.hideSoftphone();
12999
+ } else {
13000
+ this.displaySoftphone();
13001
+ }
13002
+ }
13003
+
13004
+ displaySoftphone() {
13005
+ if (!this.iframe) {
13006
+ this._createIframe();
13007
+ }
13008
+
13009
+ if (this.iframe) {
13010
+ this.iframe.style.display = 'block';
13011
+ }
13012
+
13013
+ this.displayed = true;
13014
+ }
13015
+
13016
+ hideSoftphone() {
13017
+ if (this.iframe) {
13018
+ this.iframe.style.display = 'none';
13019
+ }
13020
+ this.displayed = false;
13021
+ }
13022
+
13023
+ optionsFetched(fieldId , options ) {
13024
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
13025
+ }
13026
+
13027
+ onOptionsResults(fieldId , options ) {
13028
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
13029
+ }
13030
+
13031
+ setFormSchema(schema , uiSchema ) {
13032
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
13033
+ }
13034
+
13035
+ setCardValue(field , value ) {
13036
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
13037
+ }
13038
+
13039
+ injectCss(css ) {
13040
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
13041
+ }
13042
+
13043
+ customizeAppearance(themes , translations , assets ) {
13044
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
13045
+ }
13046
+
13047
+ _createIframe(cb = () => {}) {
13048
+ this.iframe = document.createElement('iframe');
13049
+ // $FlowFixMe
13050
+ this.iframe.width = this.width;
13051
+ // $FlowFixMe
13052
+ this.iframe.height = this.height;
13053
+ // $FlowFixMe
13054
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
13055
+ this.iframe.style.position = 'absolute';
13056
+ this.iframe.style.left = '0';
13057
+ this.iframe.style.bottom = '0';
13058
+ this.iframe.style.border = '1px solid #aaa';
13059
+ this.iframe.style.backgroundColor = 'white';
13060
+ this.iframe.src = this.url;
13061
+ this.iframe.style.display = 'none';
13062
+ this.iframe.id = 'wazo-softphone';
13063
+
13064
+ this.iframe.onload = cb;
13065
+
13066
+ // $FlowFixMe
13067
+ document.body.appendChild(this.iframe);
13068
+ }
13069
+
13070
+ _getLinks() {
13071
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
13072
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
13073
+ }
13074
+
13075
+ _onLinkClick(e ) {
13076
+ e.preventDefault();
13077
+ const number = e.target.href.split(':')[1];
13078
+
13079
+ this.makeCall(number);
13080
+ }
13081
+
13082
+ _onAuthenticated() {
13083
+ this.parseLinks();
13084
+ }
13085
+
13086
+ _onMessage(event ) {
13087
+ if (!event.data) {
13088
+ return;
13089
+ }
13090
+
13091
+ switch (event.data.type) {
13092
+ case SDK_ON_CALL_MADE:
13093
+ this.onCallMade(event.data.callSession);
13094
+ break;
13095
+ case SDK_CALL_ENDED: {
13096
+ const { callSession, content, direction, userExtension } = event.data;
13097
+ this.onCallEnded(callSession, content, direction, userExtension);
13098
+ break;
13099
+ }
13100
+ case SDK_CALL_INCOMING:
13101
+ this.onCallIncoming(event.data.callSession);
13102
+ break;
13103
+ case SDK_AUTHENTICATED:
13104
+ // $FlowFixMe
13105
+ this._onAuthenticated(event.data.session);
13106
+ this.onAuthenticated(event.data.session);
13107
+ break;
13108
+ case SDK_LOGGED_OUT:
13109
+ this.onLoggedOut();
13110
+ break;
13111
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
13112
+ const { content } = event.data;
13113
+ this.onCardSaved(content);
13114
+ break;
13115
+ }
13116
+ case BRIDGE_SEARCH_OPTIONS: {
13117
+ const { fieldId, query } = event.data;
13118
+ this.onSearchOptions(fieldId, query);
13119
+ break;
13120
+ }
13121
+ case BRIDGE_DISPLAY_LINKED_OPTION:
13122
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
13123
+ break;
13124
+ case BRIDGE_WAZO_CONTACT_SEARCH:
13125
+ this.onWazoContactSearch(event.data.query);
13126
+ break;
13127
+ case BRIDGE_ON_AGENT_LOGGED_IN:
13128
+ this.onAgentLoggedIn();
13129
+ break;
13130
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
13131
+ this.onAgentLoggedOut();
13132
+ break;
13133
+ case BRIDGE_ON_AGENT_PAUSED:
13134
+ this.onAgentPaused();
13135
+ break;
13136
+ case BRIDGE_ON_AGENT_RESUMED:
13137
+ this.onAgentResumed();
13138
+ break;
13139
+ case BRIDGE_ON_LANGUAGE_CHANGED:
13140
+ this.onLanguageChanged(event.data.language);
13141
+ break;
13142
+ case BRIDGE_ON_CALL_HELD:
13143
+ this.onCallHeld();
13144
+ break;
13145
+ case BRIDGE_ON_CALL_RESUMED:
13146
+ this.onCallResumed();
13147
+ break;
13148
+ case BRIDGE_ON_CALL_MUTED:
13149
+ this.onCallMuted();
13150
+ break;
13151
+ case BRIDGE_ON_CALL_UN_MUTED:
13152
+ this.onCallUnMuted();
13153
+ break;
13154
+ case BRIDGE_ON_DTMF:
13155
+ this.onDtmfSent(event.data.tone);
13156
+ break;
13157
+ case BRIDGE_ON_DIRECT_TRANSFER:
13158
+ this.onDirectTransfer(event.data.number);
13159
+ break;
13160
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
13161
+ this.onCreateIndirectTransfer(event.data.number);
13162
+ break;
13163
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
13164
+ this.onCancelIndirectTransfer();
13165
+ break;
13166
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
13167
+ this.onConfirmIndirectTransfer();
13168
+ break;
13169
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
13170
+ this.onIndirectCallMade(event.data.call);
13171
+ break;
13172
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
13173
+ this.onIndirectTransferDone(event.data.call);
13174
+ break;
13175
+ case BRIDGE_ON_START_RECORDING:
13176
+ this.onStartRecording();
13177
+ break;
13178
+ case BRIDGE_ON_STOP_RECORDING:
13179
+ this.onStopRecording();
13180
+ break;
13181
+ case BRIDGE_ON_CARD_CANCELED:
13182
+ this.onCardCanceled();
13183
+ break;
13184
+ case BRIDGE_ON_CALL_ANSWERED:
13185
+ this.onCallAnswered();
13186
+ break;
13187
+ default:
13188
+ this.onUnHandledEvent(event);
13189
+ break;
13190
+ }
13191
+ }
13192
+
13193
+ _sendMessage(type , payload = {}) {
13194
+ if (!this.iframe || !this.iframeLoaded) {
13195
+ this._pendingMessages.push([type, payload]);
13196
+ return;
13197
+ }
13198
+
13199
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
13200
+ }
13201
+ }
13202
+
13203
+ var Softphone$1 = new Softphone();
13204
+
12846
13205
  /* global window */
12847
13206
 
12848
13207
  const Wazo = {
@@ -12863,6 +13222,7 @@ const Wazo = {
12863
13222
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
12864
13223
  Features: Features$1,
12865
13224
  Checker,
13225
+ Softphone: Softphone$1,
12866
13226
 
12867
13227
  // Domain
12868
13228
  domain: {