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