@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();
@@ -13921,6 +13921,365 @@ class Checker {
13921
13921
  }
13922
13922
  }
13923
13923
 
13924
+ //
13925
+ /* eslint-disable no-unused-vars */
13926
+ /* global window, document */
13927
+ const BRIDGE_CONFIG_RETRIEVED = 'bridge/CONFIG_RETRIEVED';
13928
+ const BRIDGE_CREATE_OR_UPDATE_CARD = 'bridge/BRIDGE_CREATE_OR_UPDATE_CARD';
13929
+ const BRIDGE_OPTIONS_FETCHED = 'bridge/BRIDGE_OPTIONS_FETCHED';
13930
+ const BRIDGE_OPTIONS_FOUND = 'bridge/BRIDGE_OPTIONS_FOUND';
13931
+ const BRIDGE_SEARCH_OPTIONS = 'bridge/BRIDGE_SEARCH_OPTIONS';
13932
+ const BRIDGE_DISPLAY_LINKED_OPTION = 'bridge/DISPLAY_LINKED_OPTION';
13933
+ const BRIDGE_UPDATE_FORM_SCHEMA = 'bridge/BRIDGE_UPDATE_FORM_SCHEMA';
13934
+ const BRIDGE_WAZO_CONTACT_SEARCH = 'bridge/BRIDGE_WAZO_CONTACT_SEARCH';
13935
+ const BRIDGE_ON_AGENT_LOGGED_IN = 'bridge/BRIDGE_ON_AGENT_LOGGED_IN';
13936
+ const BRIDGE_ON_AGENT_LOGGED_OUT = 'bridge/BRIDGE_ON_AGENT_LOGGED_OUT';
13937
+ const BRIDGE_ON_AGENT_PAUSED = 'bridge/BRIDGE_ON_AGENT_PAUSED';
13938
+ const BRIDGE_ON_AGENT_RESUMED = 'bridge/BRIDGE_ON_AGENT_RESUMED';
13939
+ const BRIDGE_ON_LANGUAGE_CHANGED = 'bridge/BRIDGE_ON_LANGUAGE_CHANGED';
13940
+ const BRIDGE_ON_CALL_ANSWERED = 'bridge/BRIDGE_ON_CALL_ANSWERED';
13941
+ const BRIDGE_ON_CALL_HELD = 'bridge/BRIDGE_ON_CALL_HELD';
13942
+ const BRIDGE_ON_CALL_RESUMED = 'bridge/BRIDGE_ON_CALL_RESUMED';
13943
+ const BRIDGE_ON_CALL_MUTED = 'bridge/BRIDGE_ON_CALL_MUTED';
13944
+ const BRIDGE_ON_CALL_UN_MUTED = 'bridge/BRIDGE_ON_CALL_UN_MUTED';
13945
+ const BRIDGE_ON_DTMF = 'bridge/BRIDGE_ON_DTMF';
13946
+ const BRIDGE_ON_DIRECT_TRANSFER = 'bridge/BRIDGE_ON_DIRECT_TRANSFER';
13947
+ const BRIDGE_ON_CREATE_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CREATE_INDIRECT_TRANSFER';
13948
+ const BRIDGE_ON_CANCEL_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CANCEL_INDIRECT_TRANSFER';
13949
+ const BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER = 'bridge/BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER';
13950
+ const BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE';
13951
+ const BRIDGE_ON_INDIRECT_TRANSFER_DONE = 'bridge/BRIDGE_ON_INDIRECT_TRANSFER_DONE';
13952
+ const BRIDGE_ON_START_RECORDING = 'bridge/BRIDGE_ON_START_RECORDING';
13953
+ const BRIDGE_ON_STOP_RECORDING = 'bridge/BRIDGE_ON_STOP_RECORDING';
13954
+ const BRIDGE_ON_CARD_CANCELED = 'bridge/BRIDGE_ON_CARD_CANCELED';
13955
+ const BRIDGE_ENABLE_AGENT = 'bridge/BRIDGE_ENABLE_AGENT';
13956
+ const BRIDGE_SET_CARD_CONTENT = 'bridge/BRIDGE_SET_CARD_CONTENT';
13957
+
13958
+ const BRIDGE_INJECT_CSS = 'bridge/BRIDGE_INJECT_CSS';
13959
+ const BRIDGE_CUSTOMIZE_APPEARANCE = 'bridge/BRIDGE_CUSTOMIZE_APPEARANCE';
13960
+
13961
+ const SDK_CLICK_TO_CALL = 'sdk/CLICK_TO_CALL';
13962
+ const SDK_ON_CALL_MADE = 'sdk/SDK_ON_CALL_MADE';
13963
+ const SDK_CALL_ENDED = 'sdk/ON_CALL_ENDED';
13964
+ const SDK_CALL_INCOMING = 'sdk/SDK_CALL_INCOMING';
13965
+ const SDK_AUTHENTICATED = 'sdk/SDK_AUTHENTICATED';
13966
+ const SDK_LOGGED_OUT = 'sdk/SDK_LOGGED_OUT';
13967
+
13968
+ class Softphone {
13969
+
13970
+
13971
+
13972
+
13973
+
13974
+
13975
+
13976
+ // Message waiting for the iframe to be loaded
13977
+
13978
+
13979
+ onLinkEnabled(link ) {}
13980
+ onIFrameLoaded() {}
13981
+
13982
+ onCallAnswered() {}
13983
+ onCallMade(call ) {}
13984
+ onCallIncoming(call ) {}
13985
+ onCallEnded(call , card , direction , fromExtension ) {}
13986
+ onCardSaved(card ) {}
13987
+ onCardCanceled() {}
13988
+ onAuthenticated(session ) {}
13989
+ onLoggedOut() {}
13990
+
13991
+ onSearchOptions(fieldId , query ) {
13992
+ this.onOptionsResults(fieldId, []);
13993
+ }
13994
+
13995
+ onDisplayLinkedOption(optionId ) {}
13996
+ onWazoContactSearch(query ) {}
13997
+ onAgentLoggedIn() {}
13998
+ onAgentLoggedOut() {}
13999
+ onAgentPaused() {}
14000
+ onAgentResumed() {}
14001
+ onLanguageChanged(language ) {}
14002
+ onCallHeld() {}
14003
+ onCallResumed() {}
14004
+ onCallMuted() {}
14005
+ onCallUnMuted() {}
14006
+ onDtmfSent(tone ) {}
14007
+ onDirectTransfer(number ) {}
14008
+ onCreateIndirectTransfer(number ) {}
14009
+ onCancelIndirectTransfer() {}
14010
+ onConfirmIndirectTransfer() {}
14011
+ onIndirectCallMade(call ) {}
14012
+ onIndirectTransferDone(call ) {}
14013
+ onStartRecording() {}
14014
+ onStopRecording() {}
14015
+ onUnHandledEvent(event ) {}
14016
+
14017
+ init({ url, width, height, server, port, language, wrapUpDuration, enableAgent = true } = {}) {
14018
+ this.url = url || 'https://softphone.wazo.io';
14019
+ this.width = width || 500;
14020
+ this.height = height || 600;
14021
+ this.displayed = false;
14022
+ this.iframeLoaded = false;
14023
+
14024
+ this.iframeLoaded = false;
14025
+ this._pendingMessages = [];
14026
+ window.addEventListener('message', this._onMessage.bind(this), false);
14027
+
14028
+ if (!server) {
14029
+ // eslint-disable-next-line no-param-reassign
14030
+ server = 'stack.dev.wazo.io';
14031
+ }
14032
+
14033
+ const config = { server };
14034
+ if (language) {
14035
+ config.language = language;
14036
+ }
14037
+ if (port) {
14038
+ config.port = port;
14039
+ }
14040
+ if (wrapUpDuration) {
14041
+ config.wrapUpDuration = wrapUpDuration;
14042
+ }
14043
+
14044
+ this._sendMessage(BRIDGE_CONFIG_RETRIEVED, { config });
14045
+
14046
+ if (enableAgent) {
14047
+ this._sendMessage(BRIDGE_ENABLE_AGENT);
14048
+ }
14049
+
14050
+ this._createIframe(() => {
14051
+ this.iframeLoaded = true;
14052
+ this._pendingMessages.forEach(([type, payload]) => this._sendMessage(type, payload));
14053
+
14054
+ this.onIFrameLoaded();
14055
+ });
14056
+ }
14057
+
14058
+ parseLinks() {
14059
+ const links = this._getLinks();
14060
+
14061
+ links.forEach(link => {
14062
+ link.setAttribute('data-wazo-parsed', true);
14063
+ link.addEventListener('click', this._onLinkClick.bind(this));
14064
+ this.onLinkEnabled(link);
14065
+ });
14066
+ }
14067
+
14068
+ makeCall(number ) {
14069
+ this.displaySoftphone();
14070
+
14071
+ this._sendMessage(SDK_CLICK_TO_CALL, { number });
14072
+ }
14073
+
14074
+ toggleSoftphoneDisplay() {
14075
+ if (this.displayed) {
14076
+ this.hideSoftphone();
14077
+ } else {
14078
+ this.displaySoftphone();
14079
+ }
14080
+ }
14081
+
14082
+ displaySoftphone() {
14083
+ if (!this.iframe) {
14084
+ this._createIframe();
14085
+ }
14086
+
14087
+ if (this.iframe) {
14088
+ this.iframe.style.display = 'block';
14089
+ }
14090
+
14091
+ this.displayed = true;
14092
+ }
14093
+
14094
+ hideSoftphone() {
14095
+ if (this.iframe) {
14096
+ this.iframe.style.display = 'none';
14097
+ }
14098
+ this.displayed = false;
14099
+ }
14100
+
14101
+ optionsFetched(fieldId , options ) {
14102
+ this._sendMessage(BRIDGE_OPTIONS_FETCHED, { fieldId, options });
14103
+ }
14104
+
14105
+ onOptionsResults(fieldId , options ) {
14106
+ this._sendMessage(BRIDGE_OPTIONS_FOUND, { fieldId, options });
14107
+ }
14108
+
14109
+ setFormSchema(schema , uiSchema ) {
14110
+ this._sendMessage(BRIDGE_UPDATE_FORM_SCHEMA, { schema, uiSchema });
14111
+ }
14112
+
14113
+ setCardValue(field , value ) {
14114
+ this._sendMessage(BRIDGE_SET_CARD_CONTENT, { field, value });
14115
+ }
14116
+
14117
+ injectCss(css ) {
14118
+ this._sendMessage(BRIDGE_INJECT_CSS, { css });
14119
+ }
14120
+
14121
+ customizeAppearance(themes , translations , assets ) {
14122
+ this._sendMessage(BRIDGE_CUSTOMIZE_APPEARANCE, { themes, translations, assets });
14123
+ }
14124
+
14125
+ _createIframe(cb = () => {}) {
14126
+ this.iframe = document.createElement('iframe');
14127
+ // $FlowFixMe
14128
+ this.iframe.width = this.width;
14129
+ // $FlowFixMe
14130
+ this.iframe.height = this.height;
14131
+ // $FlowFixMe
14132
+ this.iframe.allow = 'camera *; microphone *; autoplay *; display-capture *';
14133
+ this.iframe.style.position = 'absolute';
14134
+ this.iframe.style.left = '0';
14135
+ this.iframe.style.bottom = '0';
14136
+ this.iframe.style.border = '1px solid #aaa';
14137
+ this.iframe.style.backgroundColor = 'white';
14138
+ this.iframe.src = this.url;
14139
+ this.iframe.style.display = 'none';
14140
+ this.iframe.id = 'wazo-softphone';
14141
+
14142
+ this.iframe.onload = cb;
14143
+
14144
+ // $FlowFixMe
14145
+ document.body.appendChild(this.iframe);
14146
+ }
14147
+
14148
+ _getLinks() {
14149
+ return [].slice.call(document.querySelectorAll('a:not([data-wazo-parsed])'), 0)
14150
+ .filter(link => link.href.indexOf('tel:') === 0 || link.href.indexOf('callto:') === 0);
14151
+ }
14152
+
14153
+ _onLinkClick(e ) {
14154
+ e.preventDefault();
14155
+ const number = e.target.href.split(':')[1];
14156
+
14157
+ this.makeCall(number);
14158
+ }
14159
+
14160
+ _onAuthenticated() {
14161
+ this.parseLinks();
14162
+ }
14163
+
14164
+ _onMessage(event ) {
14165
+ if (!event.data) {
14166
+ return;
14167
+ }
14168
+
14169
+ switch (event.data.type) {
14170
+ case SDK_ON_CALL_MADE:
14171
+ this.onCallMade(event.data.callSession);
14172
+ break;
14173
+ case SDK_CALL_ENDED: {
14174
+ const { callSession, content, direction, userExtension } = event.data;
14175
+ this.onCallEnded(callSession, content, direction, userExtension);
14176
+ break;
14177
+ }
14178
+ case SDK_CALL_INCOMING:
14179
+ this.onCallIncoming(event.data.callSession);
14180
+ break;
14181
+ case SDK_AUTHENTICATED:
14182
+ // $FlowFixMe
14183
+ this._onAuthenticated(event.data.session);
14184
+ this.onAuthenticated(event.data.session);
14185
+ break;
14186
+ case SDK_LOGGED_OUT:
14187
+ this.onLoggedOut();
14188
+ break;
14189
+ case BRIDGE_CREATE_OR_UPDATE_CARD: {
14190
+ const { content } = event.data;
14191
+ this.onCardSaved(content);
14192
+ break;
14193
+ }
14194
+ case BRIDGE_SEARCH_OPTIONS: {
14195
+ const { fieldId, query } = event.data;
14196
+ this.onSearchOptions(fieldId, query);
14197
+ break;
14198
+ }
14199
+ case BRIDGE_DISPLAY_LINKED_OPTION:
14200
+ this.onDisplayLinkedOption(event.data.linkedOptionId);
14201
+ break;
14202
+ case BRIDGE_WAZO_CONTACT_SEARCH:
14203
+ this.onWazoContactSearch(event.data.query);
14204
+ break;
14205
+ case BRIDGE_ON_AGENT_LOGGED_IN:
14206
+ this.onAgentLoggedIn();
14207
+ break;
14208
+ case BRIDGE_ON_AGENT_LOGGED_OUT:
14209
+ this.onAgentLoggedOut();
14210
+ break;
14211
+ case BRIDGE_ON_AGENT_PAUSED:
14212
+ this.onAgentPaused();
14213
+ break;
14214
+ case BRIDGE_ON_AGENT_RESUMED:
14215
+ this.onAgentResumed();
14216
+ break;
14217
+ case BRIDGE_ON_LANGUAGE_CHANGED:
14218
+ this.onLanguageChanged(event.data.language);
14219
+ break;
14220
+ case BRIDGE_ON_CALL_HELD:
14221
+ this.onCallHeld();
14222
+ break;
14223
+ case BRIDGE_ON_CALL_RESUMED:
14224
+ this.onCallResumed();
14225
+ break;
14226
+ case BRIDGE_ON_CALL_MUTED:
14227
+ this.onCallMuted();
14228
+ break;
14229
+ case BRIDGE_ON_CALL_UN_MUTED:
14230
+ this.onCallUnMuted();
14231
+ break;
14232
+ case BRIDGE_ON_DTMF:
14233
+ this.onDtmfSent(event.data.tone);
14234
+ break;
14235
+ case BRIDGE_ON_DIRECT_TRANSFER:
14236
+ this.onDirectTransfer(event.data.number);
14237
+ break;
14238
+ case BRIDGE_ON_CREATE_INDIRECT_TRANSFER:
14239
+ this.onCreateIndirectTransfer(event.data.number);
14240
+ break;
14241
+ case BRIDGE_ON_CANCEL_INDIRECT_TRANSFER:
14242
+ this.onCancelIndirectTransfer();
14243
+ break;
14244
+ case BRIDGE_ON_CONFIRM_INDIRECT_TRANSFER:
14245
+ this.onConfirmIndirectTransfer();
14246
+ break;
14247
+ case BRIDGE_ON_INDIRECT_TRANSFER_CALL_MADE:
14248
+ this.onIndirectCallMade(event.data.call);
14249
+ break;
14250
+ case BRIDGE_ON_INDIRECT_TRANSFER_DONE:
14251
+ this.onIndirectTransferDone(event.data.call);
14252
+ break;
14253
+ case BRIDGE_ON_START_RECORDING:
14254
+ this.onStartRecording();
14255
+ break;
14256
+ case BRIDGE_ON_STOP_RECORDING:
14257
+ this.onStopRecording();
14258
+ break;
14259
+ case BRIDGE_ON_CARD_CANCELED:
14260
+ this.onCardCanceled();
14261
+ break;
14262
+ case BRIDGE_ON_CALL_ANSWERED:
14263
+ this.onCallAnswered();
14264
+ break;
14265
+ default:
14266
+ this.onUnHandledEvent(event);
14267
+ break;
14268
+ }
14269
+ }
14270
+
14271
+ _sendMessage(type , payload = {}) {
14272
+ if (!this.iframe || !this.iframeLoaded) {
14273
+ this._pendingMessages.push([type, payload]);
14274
+ return;
14275
+ }
14276
+
14277
+ this.iframe.contentWindow.postMessage({ type, ...payload }, '*');
14278
+ }
14279
+ }
14280
+
14281
+ var Softphone$1 = new Softphone();
14282
+
13924
14283
  /* global window */
13925
14284
 
13926
14285
  const Wazo = {
@@ -13941,6 +14300,7 @@ const Wazo = {
13941
14300
  loggerFor: IssueReporter$1.loggerFor.bind(IssueReporter$1),
13942
14301
  Features: Features$1,
13943
14302
  Checker,
14303
+ Softphone: Softphone$1,
13944
14304
 
13945
14305
  // Domain
13946
14306
  domain: {