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